From: dgraham@bmers30.bnr.ca (Douglas Graham) Subject: Re: 0.96b PL2 Pty's broken? Date: 28 Jun 1992 08:26:51 GMT
In article <1992Jun28.041156.17524@uniwa.uwa.edu.au> oreillym@tartarus.uwa.edu.au (Michael O'Reilly) writes:
>My patch was so that if you read from a pty master after the pty slave
>was closed it immediately returns with 0. (This is correct).
Under SunOS, the read will return -1, and set errno to EIO. A read
on the slave after the master has been closed will return 0.
>Here is what I don't know:
>
>What happens when a read is done on a pty slave without a master? What
>should it return, or should it block untill the master is opened. My
>GUESS is that it should block.
Actually, I think the open is supposed to block. That way you'd
never get to the read.
>What should happen when a pty master is read from with a pty slave being
>opened. Not after the slave has closed, but before the slave is opened??
>Should it block? or return 0 immediately.
It should block I think. The problem I was having with script, and I
think this is not atypical behaviour for programs that use ptys, is
that the parent process would open the master, then fork a child which
opened the slave and connected it to a shell. The parent would then
read the master for output from the shell. The problem is that the
parent does the read before the child has a chance to open the slave.
With the latest patch, the parent would get EOF, and die immediately.
>What happens with writes in all cases??
Under SunOS, the slave never gets a chance to do a write until
the master is opened, because the open will block. If the master
has been closed, the write on the slave gets EIO. The master blocks
at a write until the slave has been opened, and gets EIO if the
slave has been closed.
>The documentation I have on pty's is VERY scanty. Does any one have
>more information on how these should work? I am very happy to fix it, I
>just need to know what it should do.
I've never seen any decent documentation.