public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Re: Regression (last snapshot)
Date: Fri, 02 Aug 2019 21:53:00 -0000	[thread overview]
Message-ID: <400eebe3-3ba9-5448-85a8-92e6e0dfdf0c@cornell.edu> (raw)
In-Reply-To: <5f4a0400-a173-1948-6048-69ba54df2571@SystematicSw.ab.ca>

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

On 8/2/2019 5:26 PM, Brian Inglis wrote:
> On 2019-08-02 08:34, Ken Brown wrote:
>> On 8/1/2019 10:32 PM, Ken Brown wrote:
>>> On 8/1/2019 5:17 PM, Ken Brown wrote:
>>>> On 8/1/2019 12:04 PM, Corinna Vinschen wrote:
>>>>> On Aug  1 10:38, Eric Blake wrote:
>>>>>> Could it be a case of xwin-xdg-menu calling signal(SIGPIPE, SIG_IGN) or
>>>>>> similar, and accidentally letting grep inherit the ignored SIGPIPE?
>>>>>
>>>>> execve doesn't propagate the signal dispositions, they get reset to
>>>>> default.
>>>>
>>> I just built a version of grep in which I added 'signal(SIGPIPE, SIG_DFL)', and
>>> the error is gone.  So it looks like grep has in fact been receiving SIGPIPE,
>>> and for some reason it is not using the default signal handler for SIGPIPE in a
>>> terminal started by xwin-xdg-menu.  Could this be a gtk issue?  Does it mess
>>> with the signal handlers?
>>
>> I think I've finally got it.
>>
>> First of all, here's what POSIX says about signal handlers after an exec:
>>
>> "Signals set to the default action (SIG_DFL) in the calling process
>> image shall be set to the default action in the new process image.
>> Except for SIGCHLD, signals set to be ignored (SIG_IGN) by the calling
>> process image shall be set to be ignored by the new process image.
>> Signals set to be caught by the calling process image shall be set to
>> the default action in the new process image (see <signal.h>)."
>>
>> Second, here's a quote from the GTK+ documentation for gtk_init():
>>
>> "Since 2.18, GTK+ calls signal (SIGPIPE, SIG_IGN) during initialization,
>> to ignore SIGPIPE signals, since these are almost never wanted in
>> graphical applications. If you do need to handle SIGPIPE for some
>> reason, reset the handler after gtk_init(), but notice that other
>> libraries (e.g. libdbus or gvfs) might do similar things."
>>
>> Third, xwin-xdg-menu calls gtk_init() near the beginning of main().
>>
>> Putting this all together, Eric's explanation is indeed correct.  All
>> processes created by xwin-xdg-menu via fork/exec inherit the property of
>> ignoring SIGPIPE.
>>
>> I don't know if this is a bug, but it certainly leads to surprising
>> behavior.  Jon, maybe xwin-xdg-menu needs to call signal(SIGPIPE,
>> SIG_DFL) either after calling gtk_init() or before calling exec()?
> 
> How does that relate to this only happening in the latest snapshot, and not in
> the current release, or any Linux system?

It does happen in the current release, as I said earlier in the thread.

There's no way to test it on Linux.  xwin-xdg-menu is a Cygwin-specific 
program (written by Jon).

> I would certainly expect any shell (or any other program handling pipes) to set
> or reset SIGPIPE handling, rather than accept any default.

Take a look at the bash source code and the grep source code.  You'll 
see that neither one of them does this.  And I don't know why you would 
expect it.

Suppose I write a program that creates a pipe, sets SIGPIPE to be 
ignored, and then creates a grep subprocess with stdout set to the write 
end of that pipe.  By doing so, I've clearly indicated my intention that 
grep should ignore SIGPIPE.  Why should grep overrule my choice?  And 
how would grep even know that it's writing to a pipe?

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-02 21:53 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
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 [this message]
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=400eebe3-3ba9-5448-85a8-92e6e0dfdf0c@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.com \
    /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).