Cygwin: Fix handling of wait pipe hangup by properly detecting EOF
authorChristian Babeux <christian.babeux@efficios.com>
Mon, 3 Dec 2012 02:09:39 +0000 (21:09 -0500)
committerChristian Babeux <christian.babeux@efficios.com>
Fri, 7 Dec 2012 20:17:55 +0000 (15:17 -0500)
commit060a32b279132ceeeef14b96a611077195a2ca46
tree70ffa612fde7cdd8ed57fda6a353a9cf6642fd1d
parent840a73344734b584f7033a2b76628b28c2fa57bf
Cygwin: Fix handling of wait pipe hangup by properly detecting EOF

On Linux, the POLLHUP poll(3) event is used to signal that the other end
of a pipe has been disconnected. Due to poor wording in the Single UNIX
Specification, differents UNIX implementation signal the EOF with
conflicting poll events [1].

This is the case on Cygwin. A pipe close sends the POLLIN poll(3) event.
The actual consumer implementation sees this has a wakeup for data
ready to be consumed. The current hangup handling leads to infinite looping
in the consumer because the hangup is never detected and the POLLIN event
is never cleared.

To fix this issue, the consumer must read on the pipe, check for EOF
(read(3) shall return 0 to indicate EOF) and proceed to force the POLLHUP
poll(3) event if this is indeed the case.

[1] - http://www.greenend.org.uk/rjk/tech/poll.html

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
src/common/consumer.c
src/common/consumer.h
src/common/ust-consumer/ust-consumer.c
src/common/ust-consumer/ust-consumer.h
This page took 0.025495 seconds and 4 git commands to generate.