opening ptys - intermitant problem

opening ptys - intermitant problem

Post by James Gallagh » Sun, 25 Jul 1993 00:25:47

I am working on a small library that runs coprocesses with a pty slave
attached to their stdin, out and err. In this library I use Stevens'
(``Advanced Programming in the UNIX Environment'') ptyfork() call to create
the child process. SunOS 4.1.3 on an IPX, compiled with gcc-2.3.3

The problem: Once the child is created, if I do a select on the pty master
file descriptor (testing for either read or write) it comes back one of two
ways: 1) the decriptor is ready for both reading and writing or 2) the
descriptor is ready for neither. In the laster case if I retry select() it
always come back after the timeout saying that neither descriptor is ready
for I/O. When this is the case the first write call to the pty master blocks

I discovered this problem while testing this small library. Sometimes I would
run the test program and it would hang, but most of the time it worked fine.
The same behavior occurs reguardless of the program used as a coprocess
(e.g., it also happens with Stevens' add2stdio program).

What am I missing? Is there a deadlock or race conditionthat I am not taking
into account? A known problem with ptyfork() on 4.1.3?

James Gallagher