pty

xterm seems to change its "home" key behaviour for emacs

xterm seems to change its "home" key behaviour for emacs In xterm, when I press the HOME key on my keyboard, it normally sends ^[[H but when I open emacs -nw, it changes to ^[OH; those are home and khome respectively. I figured out while trying to build my own terminal that ^[[H doesn’t work …

Total answers: 1

How can I connect a bash process to a tty _without_ using getty

How can I connect a bash process to a tty _without_ using getty I would have two serial usb devices connected to each other, /dev/ttyUSB1 and /dev/ttyUSB2. I would like to run /bin/bash connected to one end, so that I can attach to the other end using picocom and use picocom as a local terminal …

Total answers: 2

How to determine the graphical tty in loginctl

How to determine the graphical tty in loginctl Loginctl lists a lot of sessions, and I want programmatically to know which one is a graphical session (e.g. GNOME desktop). In the example below, I have a GNome desktop session open, an ssh connection open, and a text session (getty) open. $ loginctl SESSION UID USER …

Total answers: 1

Pseudo terminal for comms between two processes

Pseudo terminal for comms between two processes I am writing an executable that uses a 3rd party C library (libmodbus if it matters) to communicate via serial device (in my case, /dev/ttyUSB0 or similar to talk RS-485 via an FTDI chipset based USB-to-RS485 adapter). This executable, based on CLI args, can initiate commands (in my …

Total answers: 1

Why blocking read() on a pty returns when process on the other end dies?

Why blocking read() on a pty returns when process on the other end dies? When slave side of pty is not opened, strace on the process, which does read(master_fd, &byte, 1);, shows this: read(3, So, when nobody is connected to the slave side of pty, read() waits for data – it does not return with …

Total answers: 1

What does 'script /dev/null' do?

What does 'script /dev/null' do? Every time I log into a VM with root, su into a user account, and try to use screen it throws an error: Cannot open your terminal ‘/dev/pts/0’ – please check. A Stack Overflow post said I needed to use script /dev/null to fix it, and it works, but it …

Total answers: 1

BSD-style pseudoterminals vs. UNIX 98 pseudoterminals

BSD-style pseudoterminals vs. UNIX 98 pseudoterminals Based on what I have read about pseudoterminals in Linux, there are two types of pseudoterminals: BSD-style pseudoterminals (which is deprecated) and UNIX 98 pseudoterminals. I have created two images that shows my understanding of these two types of pseudoterminals. The following image shows how the BSD-style pseudoterminals works …

Total answers: 1

Why are two ^D presses necessary to exit `cat`?

Why are two ^D presses necessary to exit `cat`? Let’s run cat and then type a then ^D – you will see that cat did not exit. Compare it with cat + a + Enter + ^D – now cat did exit. So, why two ^D presses are necessary to exit cat in the first …

Total answers: 1

What is the difference between **pts** and **tty** and **:0**?

What is the difference between **pts** and **tty** and **:0**? Please help me to distinguish pts from gui mode generated from tty. booting to multi-user.target I did this: sudo systemctl set-default multi-user.target reboot login with regular user debian8 ctrlaltf2 and login with regular user debian8 too. run startx to switch into gui run tty and …

Total answers: 3

Is it possible to reuse the slave end of a PTY after closing it?

Is it possible to reuse the slave end of a PTY after closing it? After the slave end is used (open(), read(), write(), close()), the master’s read() finishes and returns with an EIO error. But I was expecting to be able to open()/close() multiple times the slave end without disrupting the master fd. Is it …

Total answers: 2

How to trick a command into thinking its output is going to a terminal

How to trick a command into thinking its output is going to a terminal Given a command that changes its behaviour when its output is going to a terminal (e.g. produce coloured output), how can that output be redirected in a pipeline while preserving the changed behaviour? There must be a utility for that, which …

Total answers: 7

How can I fix /dev/pts after mounting it?

How can I fix /dev/pts after mounting it? I made the same mistake as in this question: Debian chroot blocking PTTYs on host I mounted a “devpts” filesystem inside a chroot, and now urxvt can’t create ptys. Oddly enough xterm still can. Remounting /dev/pts doesn’t fix the issue. What can I do to get my …

Total answers: 1

How do I come by this pty and what can I do with it?

How do I come by this pty and what can I do with it? It seems that a simple shell redirect from /dev/ptmx gets me a new pseudo-terminal. $ ls /dev/pts; ls /dev/pts </dev/ptmx 0 1 2 ptmx 0 1 2 3 ptmx It disappears as soon as the process that owns the fd claim …

Total answers: 1

How do I preserve coloured output when piping to `less -R`?

How do I preserve coloured output when piping to `less -R`? $ ffmpeg -v debug … Coloured output. $ ffmpeg -v debug … |& less -R Dull output. How do I make the output coloured while piping it to something? Asked By: Vi. || Source For commands that do not have an option similar to …

Total answers: 2

Is it possible to change what tty a terminal emulator is connected to?

Is it possible to change what tty a terminal emulator is connected to? If I have a terminal emulator (say, xterm) by default it connects to a pseudoterminal like /dev/pts/3 What I would like to know is if it is possible to connect it directly to, say, tty1? Could I connect to a tty and …

Total answers: 1

How can we know who's at the other end of a pseudo-terminal device?

How can we know who's at the other end of a pseudo-terminal device? If I do a: echo foo > /dev/pts/12 Some process will read that foon from its file descriptor to the master side. Is there a way to find out what that(those) process(es) is(are)? Or in other words, how could I find out …

Total answers: 4

Which process is occupying a certain pseudo terminal pts/X?

Which process is occupying a certain pseudo terminal pts/X? On Linux: Normally pseudo terminals are allocated one after the other. Today I realized that even after a reboot of my laptop the first opened terminal window (which was always pts/0 earlier) suddenly became pts/5. This was weird and made me curious. I wanted to find …

Total answers: 2

How does a Linux terminal work?

How does a Linux terminal work? If you fire up a terminal and call an executable (assuming one that’s line oriented for simplicity) you get a reply to the command from the executable. How does this get printed to you (the user)? Does the terminal do something like pexpect? (poll waiting for output) or what? …

Total answers: 2