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.

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).

  • 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 unix.stackexchange.com/questions/492753/… – Tim Jan 6 at 5: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 6 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.