Re: CGI-Output truncated - what does POLLHUP mean?
Laurent Bercot <[email protected]> Mon, 31 Mar 2008 09:59:18 +0200
| Newsgroups | gmane.comp.web.fnord |
|---|---|
| Message-ID | <[email protected]> |
> You are supposed to get a POLLHUP if the pipe closed unexpectedly, i.e. > if there is an error on the pipe. It's been a few years since I've experimented with this, and newer kernels might have changed behaviours, but I remember getting POLLHUPs on Linux in some normal EOF situations. It happened either with pipes or with sockets - I don't remember which one: when the last batch of data (followed by EOF) arrived, poll() returned *both* POLLIN and POLLHUP. In other situations, the last batch of data just triggered POLLIN, and subsequent poll()s returned POLLHUP. The workaround for me was to always handle POLLIN first, and POLLHUP later, in the poll() loop, so the data, if any, gets read first, and the connection gets closed later. Moving the "if (x[blah].revents & POLLHUP) break ;" line to the end of the loop should make things work in every case. -- Laurent