Re: Bug in pty re-usage

Thorsten Kuehnemann (
Thu, 26 Sep 1996 13:52:32 +0200 (MET DST)

References: <> <> <52c0va$> (H. Peter Anvin) writes:
>By author: Alex deVries <>
>> fact that I've increased the number of ttys and ptys to 128 from the stock

>I suggest making sure you delete *all* /dev/[pt]ty[a-z]* and recreate
>them; this problem has been known to occur if you mix the "old" device
>numbers (major 4) with the "new" ones (majors 2-3).

No, not this problem Olaf and i described here, it does not depend on
installation environment.

The described PTY-Error is the same with the old and the new pty device
numbers (i tested this before posting).

*Please* do test it with

- xterm
- "xclock &" in that xterm
- exit that xterm
- start "script"

This bug affects _all_ pty-programs which reads from the master-pty
before opening the slave-pty, and there are some.

Programs which open the slave-pty _before_ reading the master-pty are
not affected by this bug, there are some, too.

It is definitively a bug in _all_ linux-2.0.X installations and it seems to
be easy to cure for a kernel guru who knows of the side effects when
doing changes in pty_open().

I tried my previous posted testprogram on different operating systems.
The behaviour is ok for all tested systems but Linux 2:

pty free pty used pty old slave running
HP-UX 10 /dev/ptm/pty.. read: sleeps open: EBUSY open: EBUSY -> new pty
SCO OS5 /dev/pty.. reed: sleeps open: EIO open: EIO -> new pty
Linux 2.0 /dev/pty.. read: sleeps open: EIO read: EIO -> pty not usable
AIX 3 /dev/ptc/. read: sleeps open: EIO read: sleeps -> old pty
Linux 1.2 /dev/pty.. read: sleeps open: EAGAIN read: sleeps -> old pty

Solaris24 ? - - -> new pty
Sinix 542 ? - - -> new pty

I could not test with Solaris and Sinix because of the difficulty to find
the real name of the master-pty (both Solaris and Sinix dont reuse pty's
with old slaves running).

Only Linux 2 allows the open of a pty with old slave hanging around and
gives then an error in read.

All other tested systems do it in a usable way, they do allow the reuse of
the pty (AIX 3, Linux 1.2) or deny the open of the master (HP-UX, SCO 5).

I am really shure that this is an error in the Linux-2-kernel.