Hi
I am struggling to understand why one should use pselect()/ppoll() instead of wrapping an ordinary select() or poll() call around sigprocmask(). The linux man page talks about “race conditions”, but how would such dangers occur?
I plan to use poll() for an application (since ppoll() isn’t widely supported) but wish to know how (if possible) it can be made signal safe? please see preliminary code scenario below.
Code:
void foofunc() {
int retval;
sigprocmask(...); // block certain signals
...
while(1) {
sigprocmask(...); // set empty mask
// <- can something go wrong here?
retval = poll(...); // wait indefinitely
// <- and what about here?
sigprocmask(...); // restore old mask
if (retval != -1) {
... // handle file descriptor events
} else (errno == EINTR) {
// just signal interruptions, don't panic
} else {
... // handle error
}
}
}
Any help is greatly appreciated.