Well, you're right there's no *good* way to do that. Either
1. Set the fd to blocking mode anyway. Use atexit to restre it before your program exit, and hope your shell will restore it for you if your process dies violently.
2. If you want to use the fd for things like readline, open /dev/tty instead of stdin. That should avoid most of the problems with (1).
3. Create an extra socket pair, and spawn an extra shell or process that copies stdin to the pipe (in blocking mode). You can set your end into non-blocking mode. Ugly, but seems to work. It's the function io.c:lsh_copy_file in lsh.
4. Do it your way, with select and read with the socket in blocking mode. I consider that to be an ugly kludge, just like the other alternatives.
/ Niels Möller ()
Previous text:
2003-03-19 13:54: Subject: I/O callbacks in blocking mode
Yes. But now please explain how to read asynchronously from stdin without setting it in nonblocking mode with that 'sanity' check in place?
/ Per Hedbor ()