On Fri, Oct 17, 2008, Shachar Shemesh wrote about "Kernel bug? Reading from 
master PTY when no slaves are open":
> If I try to read from a master PTY when no slaves are open I get an IO 
> error. This would be okay with me, except:
> - Select keeps flaging the fd as having read data, resulting in 100% CPU 
> utilization
> and

Hi Shachar,
I'm afraid I don't understand why you consider this to be a bug. select(),
according to its manual, is supposed to return "ready" when "it is possible to
perform the corresponding I/O operation (e.g., read(2)) without blocking".
In your case, you can indeed read() and it won't block - it will return an
error, but NOT block. It is up to your application (as a sane application)
to notice that one the fds on its select() list has an error, and drop this
fd from the list. Only a broken application would keep this broken fd on the
list and cause an infinite loop.

> - The slave end is the controlling TTY for a process, so it is possible 
> to pick up the slave part again by opening /dev/tty, at which point 
> reading from the master end, again, behaves as it should.
> 
> My main problem is that I have not found a way to wait for the master 
> end to behave sanely. At the moment, I'm stuck with leaving a dangling 
> file descriptor on the slave end to the TTY, despite there being nothing 
> useful done with that file descriptor.

You bring up an interesting point. I am not aware of a solution for this
issue. But I wonder if there's a satisfactory solution. If there was, and if
closing the last open copy of a certain pty (slave) is not final, how can
you ever recycle the masters?

> Is this a kernel bug (I have found no documentation for this behavior)? 
> Is this intentional (then how do I wait without polling for reads from 
> the master to make sense again)? Am I missing something here?

Good question :-) I'm also hearing a better answer from someone.

-- 
Nadav Har'El                        |      Sunday, Oct 19 2008, 20 Tishri 5769
[EMAIL PROTECTED]             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |"Guests, like fish, begin to smell after
http://nadav.harel.org.il           |three days." -- Benjamin Franklin

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to