Questions tagged [pseudoterminal]

41 questions
8
votes
1 answer

What is the relation between tty driver and line discipline

In the famous "The TTY demystified", the following figure is shown: from which it's seemed that the user process is communicating with the "TTY driver", which in turn communicates with the line disciplie. However, in the O'Reilly book: It seems…
YoavKlein
  • 312
  • 2
  • 10
8
votes
1 answer

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 a error. But when slave…
Igor Liferenko
  • 703
  • 4
  • 16
8
votes
2 answers

what relations are between my current controlling terminal and `/dev/tty`?

On Lubuntu 18.04, I run a shell in lxterminal. Its controlling terminal is the current pseudoterminal slave: $ tty /dev/pts/2 I would like to know what relations are between my current controlling terminal /dev/pts/2 and /dev/tty. /dev/tty acts…
Tim
  • 98,580
  • 191
  • 570
  • 977
4
votes
2 answers

Why a pair of pseudo-terminals?

My question is more about the conception and design of pty than how it works. I read chapter 64 (pseudo-terminals) of "The Linux Programming Interface" book and I can't understand why we use a pair of pseudo-terminal (ptmx, pts) and not one. When we…
etchttpd
  • 59
  • 4
4
votes
1 answer

Why are `/dev/ptmx` and `/dev/pts/ptmx` not device files?

https://unix.stackexchange.com/a/492304/674 says On Linux, using devpts, there is no master device file. The process on the master end uses a file descriptor, which it gets by opening ptmx, but there’s no corresponding device node. Did the author…
Tim
  • 98,580
  • 191
  • 570
  • 977
4
votes
2 answers

Is a virtual console running as a process and implemented based on pseudoterminal?

Linux has 7 virtual consoles, which correspond to 7 device files /dev/tty[n]. Is a virtual console running as a process, just like a terminal emulator? (I am not sure. It seems a virtual console is part of the kernel, and if that is correct, it…
Tim
  • 98,580
  • 191
  • 570
  • 977
4
votes
1 answer

Is pseudo terminals ( unlockpt / TIOCSPTLCK ) a security feature?

After having opened the master part of a pseude-terminal int fd_pseudo_term_master = open("/dev/ptmx",O_RDWR); there is the file /dev/pts/[NUMBER] created, representing the slave part of he pseudo-terminal. Ignorant persons, like me might imagine…
humanityANDpeace
  • 13,722
  • 13
  • 61
  • 107
3
votes
1 answer

read(2) blocking behaviour changes when pts is closed resulting in read() returning error: -1 (EIO)

I'm trying to figure out how I can reliably loop a read on a pt master I have. I open the ptmx, grant and unlock it as per usual: * ptmx stuff */ /* get the master (ptmx) */ int32_t masterfd = open("/dev/ptmx", O_RDWR | O_NOCTTY); if(masterfd < 0){ …
Supernovah
  • 143
  • 6
2
votes
1 answer

How to stop program of non-interactive SSH call without pseudo-terminal

Let's say I start a program with a non-interactive SSH call (without pseudo-terminal) and exit the session via CTRLC: $ ssh user@server -- sleep 123 ^C This way, the program, in this case sleep 123 for example, is still running on server, even…
finefoot
  • 2,940
  • 2
  • 21
  • 41
2
votes
1 answer

zsh zpty does not work on macOS, does work on Linux?

zsh module zsh/zpty seems to work perfectly well on my Linux virtual machine running on Apple M1 macOS machine. But the same does not work on macOS (even on the same host machine). I have tried this with both the build of zsh that comes preinstalled…
codepoet
  • 566
  • 3
  • 14
2
votes
1 answer

Do programs that create pseudoterminals emulate terminals?

The way I understand it, applications that create a pty (a master/slave pair) can be separated into 2 categories: terminal emulators (xterm, urxvt, ...), which supposedly produce graphical output the rest (docker, ssh, tmux, screen, ...), which…
x-yuri
  • 3,223
  • 10
  • 39
  • 62
2
votes
1 answer

PTY master missing read function

How can terminal emulator read from ptm device while it missing read function? There is a PTY driver: https://github.com/torvalds/linux/blob/master/drivers/tty/pty.c. I see pty_write function, but can't see something like pty_read() function. As I…
2
votes
3 answers

How can we find out the pseudoterminal master and slave from each other?

A pseudoterminal has a pair of master and slave. How can we find out the master device file from a slave device file (e.g. /etc/pts/3)? I only find /dev/ptmx and /dev/pts/ptmx, but they can't be shared by multiple slaves. Given one of the processes…
Tim
  • 98,580
  • 191
  • 570
  • 977
2
votes
1 answer

How does a terminal emulator read and write with a physical terminal device?

In a diagram from APUE, Where is a physical terminal device or virtual console for the terminal emulator read and write with? what process open, read and write with some physical terminal device or virtual console? Is it the terminal emulator?
Tim
  • 98,580
  • 191
  • 570
  • 977
2
votes
1 answer

Does pseudoterminal transfer byte stream or message?

From The Linux Programming Interface under "data transfer" under "communication", we have "byte stream", "message" and "pseudoterminal". Does pseudoterminal belong to byte stream instead, just like how pipe belongs? If not, why?
Tim
  • 98,580
  • 191
  • 570
  • 977
1
2 3