I don't think it's ugly to read in blocking mode using select. Even the examples in the manpage does it. Using stdin, actually.
/ Per Hedbor ()
Previous text:
2003-03-19 14:11: Subject: I/O callbacks in blocking mode
Well, you're right there's no *good* way to do that. Either
- 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.
- 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).
- 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.
- 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 ()