3 ms·
> If you get stuck in read(), you can't do neat things like waking up when it's time to kick a client for being idle Totally possible with another thread actin
by the8472 7y ago
> If you get stuck in read(), you can't do neat things like waking up when it's time to kick a client for being idle
Totally possible with another thread acting as watchdog timer and sending a signal which causes the read to return with EINTR which can then check a flag whether it should retry or abort. And that's for file IO. For socket IO you can just set it to non-blocking.
- kragen 7y agoFile I/O is usually not interruptible with signals. An alternative to putting the watchdog timer in another thread is to use alarm(2) and use the kernel's built-in watchdog timer, and the default behavior for SIGALRM is probably adequate. This might be easier than non-blocking I/O.