2

In bash in lxterminal

$ tty
/dev/pts/2
$ ls /dev/ptmx -l
crw-rw-rw- 1 root tty 5, 2 May 26 09:38 /dev/ptmx

On Ubuntu, is there only one master for all the processes, and all the slaves are paired with the same master?

If different slaves are paired with different masters,

  • why is only one master shown above?
  • how can I find out the master for a given slave, and find out the slave for a given master?

Thanks.

Tim
  • 101,790

1 Answers1

1

1) Pseudo-terminals are created pairwise. Each time you open a slave, you get a new master.

2) There is only one "master" device visible in /dev/ because this is how creation of pairs is implemented. So this device doesn't represent a single master device, nor does it represent a particular master device of some random pair.

Read the man page or online docs for details how the creation process works.

3) To my knowledge, you can't directly (though it may be possible with kernel instrumentation or similar workarounds).

dirkt
  • 32,309
  • 1
    Psst! ptsname() – JdeBP May 26 '18 at 17:04
  • Thanks. "this device doesn't represent a single master device, nor does it represent a particular master device of some random pair." What does /dev/ptmx represent? See also https://unix.stackexchange.com/questions/492753/why-are-dev-ptmx-and-dev-pts-ptmx-not-device-files – Tim Jan 06 '19 at 05:03
  • @Tim /dev/ptmx represents an API endpoint to create a master/slave pair, or, "this is how creation of pairs is implemented". – dirkt Jan 06 '19 at 09:52