delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/08/02/17:54:03

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:from:to:subject:date:message-id:references
:in-reply-to:content-type:content-id:content-transfer-encoding
:mime-version; q=dns; s=default; b=gpTDBksluVC4Kpj2SaIEslR5EbXI/
I3+18hLQNe27Vt3WkxQwrVDYRDzKMBq3D1g79FYwbtXvj79geBfP4+837a7NdxJF
ZfjfMRj6dpYNTP9p87xOV87Pkk8Tvd9daSnSzVkWESaHMs0frgfl/4e/XRZe6uiv
zPleoNEm1j5trQ=
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:from:to:subject:date:message-id:references
:in-reply-to:content-type:content-id:content-transfer-encoding
:mime-version; s=default; bh=IJOykR6g9GpQJeGd11VzRL38jUE=; b=B2a
Nbc8A1LoYf6Gasi3LQ4ZiruU6ZKLaDdEC/QXNvETBELvT8X9nCuQKfRRAlVvvvHM
vKY7b+0323gizhJbUVEIEWGh7Sevasyld3fy91fNnNKt96sAHcbecTzmZvQXqe2o
sUPumaMpoFcauY3dU5rMQlrcIYhWkIjYVf0BbAG0=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=
X-HELO: NAM01-SN1-obe.outbound.protection.outlook.com
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V3sruH/tm3Y5hfHzbbz6xJ6Ubv4/qe2CoERgt+8geEN4gmXCnMaewmsZCzophOMmF7jkoRp/IyObrhkwrBUaCn2BI3uc/ovUHxLN0YG1NsDiUxwZZbk/Cv1YbJyCjNa2g6v0Og746wz5uIFlsqTRUWS613+gjDs8M+UobX0dsfp2dp4sF2TvoqCvAuKgzzE1xoTzYzr0FsHEN+SlzfB8KyEkSamp5tyqhoq3MYIk29OweKhRgEZNfTTlA6bRfVvOvKsnXIY2dl1m2ttUJBlSUaAK6+OJmN1xZ0D6zEmUz1qGc7EFNLPtJZUtjeprz5o+TD+haVZYFst9Xlc+6c4bww==
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=lu4AIU52ON5uUorj2IrTna45A97ZrD2/c7UQgB6/vhQ=; b=hVPSHiVb98bVgWjx65HqM2W9MtWJfd7cXytmfImUeTnrESZmgQ62N8l3AgLbOgjcVzo7F4LzUcyXbI7FLkpSxWBLDYZ0Ejrf5N9og1aeioDaCMRb8ipU/DuygXHVxyJG8Y02jN4r7zztzQajlntNsB9I8u3e8MkbAOZ2Rrp1hamH7dGxopSLPqUdP2Wexo+BXJ7+0IZW82pmEJkCTsggtYsvpy3f/g/ED3QgJOqeLc/yeqRnIdsp9Hl9RKimreG8JnZaWi7L/3ohBV2UAZCG/NvY706Sy88lSQwMtpkXMeEpr+KoB/FnXk0OT+QTk5zQZVfHK+dIv21uIPkvcd6+Ug==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lu4AIU52ON5uUorj2IrTna45A97ZrD2/c7UQgB6/vhQ=; b=TU+xz2Eil3tUWH6J61vqQlKmLD2N90AMoCXtxJn527OW3V9QRoS/5BQNVZFDbZkqYkFITf7LM2prD79in4h321iqHxiMGjPd5wxyQboTLxScVKEi8Xy1jpZ+rlNBDc+5h0GafegZ5kxqsFuEbSE+WCgXsi31K6NNmE3M7s44j+U=
From: Ken Brown <kbrown AT cornell DOT edu>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Re: Regression (last snapshot)
Date: Fri, 2 Aug 2019 21:53:09 +0000
Message-ID: <400eebe3-3ba9-5448-85a8-92e6e0dfdf0c@cornell.edu>
References: <20190729134700 DOT GO11632 AT calimero DOT vinschen DOT de> <ced2750a-0a52-1396-b6c1-f4228116bde7 AT cornell DOT edu> <20190729152327 DOT GQ11632 AT calimero DOT vinschen DOT de> <20190729154049 DOT GR11632 AT calimero DOT vinschen DOT de> <c5d01965-80b9-cece-54d2-f7462f84c0a2 AT cornell DOT edu> <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> <a61264b5-80da-52fc-7093-8e8d9a8ace33 AT redhat DOT com> <20190801160440 DOT GC11632 AT calimero DOT vinschen DOT de> <19e73527-cb9a-a106-a57a-2895b8a520c9 AT cornell DOT edu> <e922144a-1f02-9398-4223-dbf76c69231f AT cornell DOT edu> <b4d57d88-3ec4-939f-c591-e50aaef607f3 AT cornell DOT edu> <5f4a0400-a173-1948-6048-69ba54df2571 AT SystematicSw DOT ab DOT ca>
In-Reply-To: <5f4a0400-a173-1948-6048-69ba54df2571@SystematicSw.ab.ca>
user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
authentication-results: spf=none (sender IP is ) smtp.mailfrom=kbrown AT cornell DOT edu;
x-ms-oob-tlc-oobclassifiers: OLM:10000;
received-spf: None (protection.outlook.com: cornell.edu does not designate permitted sender hosts)
x-ms-exchange-senderadcheck: 1
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: ksb2 AT cornell DOT edu
X-IsSubscribed: yes
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id x72LrjuR026030

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

--
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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019