2
votes

I try to open a network connection through a pair of pseudo tty's on linux os.

# slattach -v /dev/ptmx
cslip started on /dev/ptmx interface sl0

OK, this was the "creating side" for the pseudo tty.

I can look in /dev/pts and find the new pty there. If I now try to use slattach also on this side I got:

slattach -v /dev/pts/3
slattach: tty_open(/dev/pts/3, RW): Input/output error

I traced with strace:

28 5505  write(1, "slattach: tty_open: trying to op"..., 46) = 46
29 5505  open("/dev/pts/3", O_RDWR|O_NONBLOCK) = -1 EIO (Input/output error)
30 5505  write(2, "slattach: tty_open(/dev/pts/3, R"..., 55) = 55
31 5505  exit_group(3)

All this happens on different distros of ubuntu, tested on 10.04 and 11.04, both are failing.

What I'm doing wrong?

1

1 Answers

1
votes

You may want to take a look at the man page pty(7).

Basically, /dev/ptmx uses the Unix 98 pseudo-terminal interface and requires that your program uses grantpt(3) and unlockpt(3). Here, slattach (the one that opens /dev/ptmx, not the other one) doesn't do so, and any program that tries to open the slave pseudo-terminal associated to the master will fail, as you experienced.

You can force slattach to do grantpt() and unlockpt() by overloading the open() call with an external routine, see this example