I'm using select.poll on Ubuntu with a socket and have registered POLLIN, POLLERR, and POLLHUP.
My understanding is that the condition when a POLLIN event occurs and recv() returns no data indicates that the peer has disconnected. My testing seems to verify this.
But why do I not get POLLHUP? Does this have different semantics?
The event value is a bitmap.  
If you get POLLIN(value:1), you have something to read,
If you get POLLHUP(value:16), your input is ended,
So when you get POLLIN(1) & POLLHUP(16) = 17, that meanss that your input is ended and that your have still something to read from the buffer,  
After you read everything from the buffer, you get only POLLHUP alone everytime you call poll() :
In that case, it is no use to keep a file descriptor in the poll list,
it is better to unregister this file descriptor immediately.
Python: select.POLLHUP