Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

poll implemenation on linux vs poll implementation on solaris

Tags:

c

linux

solaris

During debugging our application in linux enviroment we can observe that some events - POLLHUP|POLLIN occur only on linux. Our application uses unix sockets. When we do:

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}])

That situation never occurs in solaris (same 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

Can You please explain me what is the difference between poll in solaris and poll in liunx ? Thx in advance for all answers.

like image 358
JosiP Avatar asked May 16 '12 13:05

JosiP


1 Answers

Both, Linux and Solaris, used to fail to set POLLIN for EOF on some types of files, especially pipes. A common workaround was checking for POLLHUP and POLLIN together. As far as I know, the Linux core developers kept it that way (probably intended), whilst the Solaris fellows changed that behavior to use POLLIN POLLEOF.

However, this should be no issue for your application: In order to increase an application's portability, one would always check for both flags in the bit-mask.

Cheers!

like image 110
mjhennig Avatar answered Nov 15 '22 09:11

mjhennig