Strange behavior from poll() when interrupted by signal

"Yarin" <[email protected]>
Newsgroups gmane.os.openbsd.advocacy
Message-ID <[email protected]>
Hello,

As the documentation explains, when poll() is interrupted by a signal, it should return -1/EINTR.
However, I'm getting a return indicating that all of the polling descriptors are ready, but when I check their flags out, none of them are
ready. (Note that the same code behaves as expected on Linux)

This is on the Generic 4.7 release kernel.

Here's a snippet of code that I wrote to deal smoothly this behavior: (specifically, the last line)


   pollfd wait_fd[2];
   wait_fd[0].fd = sock_fd;
   wait_fd[0].events = POLLOUT;
   wait_fd[1].fd = abort_fd;
   wait_fd[1].events = POLLIN;
   int rfds;
   do
      rfds = poll(wait_fd, 2, NULL);
   while((rfds < 0 && errno == EINTR) || (rfds > 0 && !wait_fd[0].revents && !wait_fd[1].revents));


The thing is, I have no idea if this this is a feature or bug, or what. :-P

Thanks for any input,

Yarin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.