> I may be missing something in your curses non-blocking case, but > can't you work around the issue by setting up an independent file > descriptor, and hence tty structure, by performing a dup2(2) on stdin > and then closing the original stdin file descriptor?
No. dup2, like dup, creates another file descriptor reference to the original open file table entry. (Something very much like that is how stdin and stdout got set up to begin with.) Furthermore, in the case of non-blocking I/O, it is the underlying object (the tty, here) that is nonblocking, not the open file table entry and definitely not the file descriptor. As Taylor R Campbell said, nonblocking really _should_ be a property of the operation, not of the descriptor, not of the open file table entry, and _definitely_ not of the object. The only way I've thought of to work around this is to fork a helper process which reads - blockingly - from stdin and writes the data to a pipe; that pipe is then set nonblocking in the main process and is independent of everything else. I might need a third process to make the reader process die reliably.... /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML mo...@rodents-montreal.org / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B