This is the mail archive of the
mailing list for the Cygwin project.
Re: Regression (last snapshot)
- From: Ken Brown <kbrown at cornell dot edu>
- To: Jon Turney <jon dot turney at dronecode dot org dot uk>, The Cygwin Mailing List <cygwin at cygwin dot com>
- Date: Thu, 1 Aug 2019 15:30:09 +0000
- Subject: Re: Regression (last snapshot)
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=cornell.edu;dmarc=pass action=none header.from=cornell.edu;dkim=pass header.d=cornell.edu;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q3Pkga9YlOHpYc6fL2c+E0ggIHAvAQ1Q5yBiaiy4o9E=; b=LF6FZiT9xtglv294oPzjgEOZeNWG3CXPu3ayPCo+vZCP/iuk0WeYw+aok/4r5V/f9/6OcaN5XJc/NtHhllKpDrqLAI96gPOBXE6/tS7YenrRv1P7ANR7zxL3S8Ygf7yyH5dGWVPDQLBwO7E2hF/UBgFdwQnzftAulWWucfTbZlDUTSb4JaRsXNSpdiYRsSrOC1jpwJrInEAv88evxnNRvAFZHZZc8RcvPkpxAsGxCEOoqFYv9a3nHgOQ3CbG0b9wN7Fy4O8QWkI3Z/UB33gA5RCgp+EEtNhMfbcbwuZWC7bE8E17bEz6rxsacgbiHSP8eR43eqpmvSeQ4mN+20dLFA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GUmu5jK+8piWl0IwO/vNpuDVQ8hhLte6WGIWxfdZMSwCqRXFHbYS+tyjeA4veVRlJTZjZRPXKzOw7VkXntp1NVt0ByEXRPsZGSSktSi9nAUzJW74lKY5wBu6Sb6/t+5WInEXW0WUG3gctBWvBXu0LUlCbKfrz50Pf27+En2Pqkgvr2bV8V944FnBc3UG1ajswD5HcC0VVnyNerwA4Fvx5kOZl3pUh483CiVfRbvLwTdAu4r0/kUgwqe4mhL4ImXM7sByLAffr1r7w0efe4pcAPIyDXCvbT7TZSrje1tk2XcbAgonKbO1tXf5in5+1zOYWidE5ZkKC4KKj++cZNi4XQ==
- References: <20190722164509.GG21169@calimero.vinschen.de> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <20190729084552.GL11632@calimero.vinschen.de> <firstname.lastname@example.org> <20190729134700.GO11632@calimero.vinschen.de> <email@example.com> <20190729152327.GQ11632@calimero.vinschen.de> <20190729154049.GR11632@calimero.vinschen.de> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com>
On 8/1/2019 10:27 AM, Jon Turney wrote:
> On 31/07/2019 19:00, Ken Brown wrote:
>> On 7/31/2019 11:53 AM, Ken Brown wrote:
>>> On 7/29/2019 2:55 PM, Ken Brown wrote:
>>>> Here's the error that I can reproduce easily in xterm:
>>>> $ ls <(grep bash .bashrc)
>>>> grep: write error: Broken pipe
>>>> This happens 98% of the time. Notice that I used plain 'ls' rather
>>>> than the
>>>> original 'ls -lL'. With the latter, I get the broken pipe error 60%
>>>> of the time
>>>> rather than 98%:
>>>> $ ls -lL <(grep bash .bashrc)
>>>> pr-------- 1 kbrown None 0 2019-07-29 14:46 /dev/fd/63
>>>> grep: write error: Broken pipe
>>>> What about the explanation I tried earlier, but perhaps not clearly:
>>>> ls prints
>>>> /dev/fd/63 and then exits, thereby closing the read end of the pipe,
>>>> while grep
>>>> (running asynchronously) hasn't finished writing to the write end of
>>>> the pipe.
>>>> The fact that I get the broken pipe error more often with plain 'ls'
>>>> than with
>>>> 'ls -lL' is consistent with that. And the fact that I get no errors
>>>> with 'cat
>>>> <(grep bash .bashrc)' is also consistent with it, since cat doesn't
>>>> exit until
>>>> grep has finished writing.
>>>> On the other hand, this doesn't explain why I see the error only
>>>> under xterm,
>>>> nor does it explain why you can't reproduce it at all.
>>> I've made some progress. It turns out that the problem only occurs
>>> in terminals
>>> launched from the xwin-xdg-menu tray icon. I can even launch a
>>> mintty window
>>> from that icon (System Tools -> Cygwin Terminal) and I'll see the
>>> problem. On
>>> the other hand, I can launch an xterm without using that icon (e.g.,
>>> xterm -l&' from a mintty window) and I won't see the problem.
>>> So the issue has something to do with how xwin-xdg-menu launches
>>> and how that interacts with bash's process substitution. I've just
>>> the xwin-xdg-menu source and will see if I can figure out what's
>>> going on. I've
>>> also added Jon to the CC in case he has a chance to take a look.
>> OK, when xwin-xdg-menu launches an application, it creates two pipes
>> and sets
>> the application's stdout and stderr to the write ends of those pipes.
>> example, here's what I see when I launch mintty from xwin-xdg-menu:
>> $ pgrep mintty
>> $ ls -l /proc/5375/fd
>> total 0
>> lrwxrwxrwx 1 kbrown None 0 2019-07-31 13:37 0 -> /dev/null
>> lrwxrwxrwx 1 kbrown None 0 2019-07-31 13:37 1 -> pipe:
>> lrwxrwxrwx 1 kbrown None 0 2019-07-31 13:37 2 -> pipe:
>> lrwxrwxrwx 1 kbrown None 0 2019-07-31 13:37 3 -> /dev/ptmx
>> lrwxrwxrwx 1 kbrown None 0 2019-07-31 13:37 4 -> /dev/windows
>> These pipes are apparently used for logging.
> That's correct. Writes to those pipes are drained into the session
> logfile (~/.xsession-errors), which you can view with the 'View logfile'
> menu item.
>> I don't see how this would explain my observations (grep reporting a
>> pipe), but it is at least a difference between a terminal started from
>> xwin-xdg-menu and an "ordinary" terminal.
>> Anyway, I don't see any evidence here of a Cygwin bug.
> I'm not so sure: these pipes for stdout/stderr of the mintty process
> shouldn't have any influence at all on the child bash process (since
> it's stdin/stdout/stderr is the slave end of a pty), but apparently they
> somehow do?
Well, I can't be sure that the pipes are responsible. It's just that
the existence of the pipes is the only difference I could spot between
an ordinary terminal and a terminal started from xwin-xdg-menu.
Is it possible that the logging somehow slows things down or changes the
buffering, so that the grep process takes longer to complete? This
would be consistent with my theory that the broken pipe error doesn't
really represent a bug, but rather it reflects the fact that ls exits
before grep has finished writing.