poll implemenation on linux vs poll implementation on 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.


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!

链接地址: http://www.djcxy.com/p/10778.html

上一篇: 什么是在这里拆分字符串的好方法?

下一篇: Linux上的轮询实现与solaris上的轮询实现