public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: Jon Turney <jon.turney@dronecode.org.uk>,
	The Cygwin Mailing List	<cygwin@cygwin.com>
Subject: Re: Regression (last snapshot)
Date: Thu, 01 Aug 2019 15:30:00 -0000	[thread overview]
Message-ID: <12269538-c387-1f1e-ab5a-b36b60d09937@cornell.edu> (raw)
In-Reply-To: <33aead20-540c-ee3b-0d38-ff053fbac040@dronecode.org.uk>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 4388 bytes --]

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)
>>>> /dev/fd/63
>>>> 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., 
>>> 'DISPLAY=:0
>>> 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 
>>> applications,
>>> and how that interacts with bash's process substitution.  I've just 
>>> downloaded
>>> 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.  
>> For
>> example, here's what I see when I launch mintty from xwin-xdg-menu:
>>
>> $ pgrep mintty
>> 5375
>>
>> $ 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:[38654736160]
>> lrwxrwxrwx 1 kbrown None 0 2019-07-31 13:37 2 -> pipe:[42949703456]
>> 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 
>> broken
>> 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.

Ken
\x03B‹KCB”\x1c›Ø›\x19[H\x1c™\^[ܝ\x1cΈ\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0e‹ËØÞYÝÚ[‹˜ÛÛKÜ\x1c›Ø›\x19[\Ëš\x1d^[[\x03B‘TNˆ\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0e‹ËØÞYÝÚ[‹˜ÛÛKÙ˜\KÃB‘^[ØÝ[Y[\x18]\x1a[ÛŽˆ\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0e‹ËØÞYÝÚ[‹˜ÛÛKÙ^[ØÜËš\x1d^[[\x03B•[œÝXœØÜšX™H\x1a[™›Îˆ\b\b\b\b\b\x1a\x1d\x1d\x1c\x0e‹ËØÞYÝÚ[‹˜ÛÛKÛ[\vÈÝ[œÝXœØÜšX™K\Ú[\^[\x19CBƒB

  reply	other threads:[~2019-08-01 15:30 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-20 22:55 Houder
2019-07-21  9:38 ` Houder
2019-07-21  9:42   ` Houder
2019-07-22 12:23 ` Ken Brown
2019-07-22 13:44   ` Ken Brown
2019-07-22 15:20     ` Corinna Vinschen
2019-07-22 15:53       ` Corinna Vinschen
2019-07-22 16:45         ` Corinna Vinschen
2019-07-22 18:47           ` Houder
2019-07-26 22:12             ` Ken Brown
2019-07-27  0:14               ` Ken Brown
2019-07-27 10:21               ` Houder
2019-07-27 15:24                 ` Ken Brown
2019-07-27 16:25                   ` Houder
2019-07-29  8:45                   ` Corinna Vinschen
2019-07-29 13:18                     ` Ken Brown
2019-07-29 13:35                       ` Ken Brown
2019-07-29 13:48                         ` Corinna Vinschen
2019-07-29 13:47                       ` Corinna Vinschen
2019-07-29 14:26                         ` Ken Brown
2019-07-29 15:23                           ` Corinna Vinschen
2019-07-29 15:40                             ` Corinna Vinschen
2019-07-29 18:56                               ` Ken Brown
2019-07-31 15:53                                 ` Ken Brown
2019-07-31 18:00                                   ` Ken Brown
2019-08-01  9:01                                     ` Corinna Vinschen
2019-08-01 14:27                                     ` Jon Turney
2019-08-01 15:30                                       ` Ken Brown [this message]
2019-08-01 15:38                                         ` Eric Blake
2019-08-01 16:04                                           ` Corinna Vinschen
2019-08-01 21:17                                             ` Ken Brown
2019-08-02  2:32                                               ` Ken Brown
2019-08-02 14:34                                                 ` Ken Brown
2019-08-02 15:04                                                   ` Corinna Vinschen
2019-08-02 21:26                                                   ` Brian Inglis
2019-08-02 21:53                                                     ` Ken Brown
2019-08-02 21:58                                                       ` Eric Blake
2019-08-03  3:50                                                         ` Brian Inglis
2019-08-03 13:14                                                           ` Ken Brown
2019-08-04 16:52                                                   ` Houder
2019-08-01 10:03                                   ` Houder
2019-08-01 10:46                                     ` Houder
2019-08-01 12:20                                     ` Ken Brown
2019-08-01 14:29                                       ` Houder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12269538-c387-1f1e-ab5a-b36b60d09937@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.com \
    --cc=jon.turney@dronecode.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).