X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=ngbsBwyCWzmp8DoK i+LwtxwpOeSQEnVXFTpflhGd2x1UKBgGDUOlS2pL+D0R7UsxJCVtpfFIDMlH+Xgi R+Ex+mnyXFdcVCpKWoROcoI34m6FudeNN+cCAnllB3nWgPhXt2Guiur/bSn9naCU P7JnJFvN1IMY5+I+O2ZQoocicus= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=KjZ28/kztARxAfj6N3a8Dy g9tdw=; b=dxssmneFHtRyH4znN8kLyB1VotsUdzQQ7OlFCST8nFoalpU5Sb4MVK vACpcPiracAqLorCBoIfFCQqwmpzOUAOuLw/+9uuEAbfewH8iDVwbpuhsuP19oL1 mKRrQGJ6DvmG7CUQFjDuaLcdi+CELN0FjLxse1HCAqBZPH+o/Fgi4= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca Subject: Re: Regression (last snapshot) To: cygwin AT cygwin DOT com References: <20190729134700 DOT GO11632 AT calimero DOT vinschen DOT de> <20190729152327 DOT GQ11632 AT calimero DOT vinschen DOT de> <20190729154049 DOT GR11632 AT calimero DOT vinschen DOT de> <8e57d4da-722d-1b9a-bd28-5f96ed182f6a AT cornell DOT edu> <0a09679b-1a0f-613b-04c8-1a63da8a00c2 AT cornell DOT edu> <33aead20-540c-ee3b-0d38-ff053fbac040 AT dronecode DOT org DOT uk> <12269538-c387-1f1e-ab5a-b36b60d09937 AT cornell DOT edu> <20190801160440 DOT GC11632 AT calimero DOT vinschen DOT de> <19e73527-cb9a-a106-a57a-2895b8a520c9 AT cornell DOT edu> From: Brian Inglis Openpgp: preference=signencrypt Message-ID: <5f4a0400-a173-1948-6048-69ba54df2571@SystematicSw.ab.ca> Date: Fri, 2 Aug 2019 15:26:54 -0600 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 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