bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lib/poll.c, win32 SIGHUP on pipes


From: Erik Faye-Lund
Subject: Re: lib/poll.c, win32 SIGHUP on pipes
Date: Mon, 23 Aug 2010 01:30:45 +0200

On Mon, Aug 23, 2010 at 12:32 AM, Erik Faye-Lund <address@hidden> wrote:
> I've recently looked into replacing the poll-emulation in Git for
> Windows with the code from gnulib, due to the improved pipe-support in
> gnulib.
>
> However, I've noticed that win32_compute_revents() never returns
> SIGHUP for FILE_TYPE_PIPE, which is something the code I'm trying to
> port currently depends on. What seems to happen is the following: one
> of the pipe-ends is closed, and thus PeekNamedPipe() fails.
> win32_compute_revents() mistakenly believes that the failure means
> that the pipe can be written because NtQueryInformationFile succeeds
> and returns 8192 for both fpli.WriteQuotaAvailable and
> fpli.OutboundQuota.
>
> In my case, a simple "happened |= POLLHUP;"-hack in the error-case
> solves the issue in this particular case, but this is obviously not
> correct in the general case.
>
> My guess is that a proper solution would be to find device a robust
> way of checking if a pipe is closed or not. I haven't looked much into
> this yet, but at least GetNamedPipeInfo() doesn't seem to error out on
> my pipe.
>

The following seems to work:

diff --git a/lib/poll.c b/lib/poll.c
index 49c4159..83532c4 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -150,6 +150,8 @@ win32_compute_revents (HANDLE h, int *p_sought)
           if (avail)
             happened |= *p_sought & (POLLIN | POLLRDNORM);
         }
+      else if (GetLastError() == ERROR_BROKEN_PIPE)
+        happened |= POLLHUP;

       else
         {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]