From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101704 invoked by alias); 2 Aug 2019 21:26:59 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 101697 invoked by uid 89); 2 Aug 2019 21:26:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=relate, discretion X-HELO: smtp-out-no.shaw.ca Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Aug 2019 21:26:57 +0000 Received: from [192.168.1.114] ([24.64.172.44]) by shaw.ca with ESMTP id tf4gh1UCCsAGktf4hhZLFP; Fri, 02 Aug 2019 15:26:55 -0600 Reply-To: Brian.Inglis@SystematicSw.ab.ca Subject: Re: Regression (last snapshot) To: cygwin@cygwin.com References: <20190729134700.GO11632@calimero.vinschen.de> <20190729152327.GQ11632@calimero.vinschen.de> <20190729154049.GR11632@calimero.vinschen.de> <8e57d4da-722d-1b9a-bd28-5f96ed182f6a@cornell.edu> <0a09679b-1a0f-613b-04c8-1a63da8a00c2@cornell.edu> <33aead20-540c-ee3b-0d38-ff053fbac040@dronecode.org.uk> <12269538-c387-1f1e-ab5a-b36b60d09937@cornell.edu> <20190801160440.GC11632@calimero.vinschen.de> <19e73527-cb9a-a106-a57a-2895b8a520c9@cornell.edu> From: Brian Inglis Openpgp: preference=signencrypt Message-ID: <5f4a0400-a173-1948-6048-69ba54df2571@SystematicSw.ab.ca> Date: Fri, 02 Aug 2019 21:26:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00031.txt.bz2 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 )." > > 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? Has it been tried under Linux/xterm/bash? I would certainly expect any shell (or any other program handling pipes) to set or reset SIGPIPE handling, rather than accept any default. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple