From: Christian Babeux Date: Mon, 3 Dec 2012 02:09:39 +0000 (-0500) Subject: Cygwin: Fix handling of wait pipe hangup by properly detecting EOF X-Git-Url: http://git.lttng.org/?a=commitdiff_plain;h=060a32b279132ceeeef14b96a611077195a2ca46;hp=060a32b279132ceeeef14b96a611077195a2ca46;p=lttng-tools.git 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 ---