4 ms·
[ Replying to myself since I'm past the edit window. ] That was it. I tested it with sigaction(), and when SIGALRM is delivered, wait() returns immediately and
by adrianmonk 2y ago
[ Replying to myself since I'm past the edit window. ]
That was it. I tested it with sigaction(), and when SIGALRM is delivered, wait() returns immediately and sets errno to EINTR.
But if I pass the SA_RESTART flag to sigaction(), wait() keeps waiting just like when I used signal().
So yeah, it would work, and you can the same method for timeouts on lots of other system calls too.
- GoblinSlayer 2y agoLinux kernel signal syscall works without restart, but glibc wrapper for signal calls sigaction with SA_RESTART (BSD semantics). I had impression all wait functions are unconditionally interrupted, but wait(2) indeed respects SA_RESTART.