select/poll and Signal Safety


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() isnt 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.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!