Linux Poll Versus Solaris Poll Implementation

When debugging our application in linux environment, we can notice that some events - POLLHUP|POLLIN are found only in Linux. Our application uses UNIX sockets. When we do this:

 ret = poll(xpoll->pfd, xpoll->pfd_count, xpoll_timeout); 

strace shows:

 poll([{fd=4, events=POLLIN|POLLPRI|POLLERR|POLLHUP}, {fd=6, events=POLLIN|POLLPRI|POLLERR|POLLHUP}, {fd=7, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 3, 16) = 1 ([{fd=7, revents=POLLIN|POLLHUP}]) 

This situation never occurs in Solaris (single application): struss shows:

 2463/3: fd=569 ev=POLLIN|POLLPRI|POLLERR|POLLHUP rev=0 2463/3: fd=639 ev=POLLIN|POLLPRI|POLLERR|POLLHUP rev=0 2463/3: fd=631 ev=POLLIN|POLLPRI|POLLERR|POLLHUP rev=POLLIN 2463/3: fd=1160 ev=POLLIN|POLLPRI|POLLERR|POLLHUP rev=0 2463/3: fd=400 ev=POLLIN|POLLPRI|POLLERR|POLLHUP rev=0 

Could you explain to me what is the difference between polling in Solaris and polling in liunx? Thanks in advance for all the answers.

+7
source share
1 answer

Both, Linux and Solaris, used to not install POLLIN for EOF for some types of files, especially pipes. A common workaround is to check POLLHUP and POLLIN together. As far as I know, the main Linux developers saved it this way (perhaps it was supposed to), while the Solaris fellows changed this behavior to use POLLIN POLLEOF.

However, this should not be a problem for your application: to increase portability of the application, you always need to check both checkboxes in the bitmask.

Hooray!

+3
source

All Articles