This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Regression (last snapshot)
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Fri, 2 Aug 2019 14:34:02 +0000
- Subject: Re: Regression (last snapshot)
- 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
- 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=aChYVt+ieHiWm7YlJ8Jw0d+Go0pj/gdRENqXtuZ+3/4=; b=mQe5RuwT48Br+A2pZ13RVSWF3UjrUz/mg5JTQyGgKe7VgOPQdxJKQC9rhXn1WxJEiGx9fC7DVXSnysK7vCpGQCHIvb0/jGpyj1V5vzM7mrz7Zm7BwoEMr8U2lwusY84dki8b/zoCTrz8/1NaTUFkN1nenxBvg6KKtKkKtMPoXyy9YSJ0/a2RpWN4etyERgDmY9Wc9TlXbk3o5FJSgB8JeyQVtNGkT0+bu91EJ02lT0TWA2EKJ61Gtm4HTxm2eIgdG12A3DTE1khhuyHy/O00ml8KAKP1Z3bmJr8HwVaf9fxetVFOzgi0QSB9gqchAE0PY7eRyDF+2YEOE25bT+9FAQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QIgWdvBFFXu4816nGioS7JBBUQYLkC42QwHVXkIBO5LZTnDBZTRKwIXEo3cc9/yC3EnYLDAFb21aPvmxI1kjz4u7mtWiMHC/ONEacp+Piabx2LNtfXlUgraLs5YRBkrSTYqekffpSrw7JBi3doz0coCIuqbeQ2u0J8YDSSq0CuzyXH1I++VNL9IfjS9tLwDfZLvMGbNjkRukMcwyUuV31MtLZ6UdECmPSvhRNAjYcngj4WSmn9fJYMQGv/NVpexEZNABMLoJ7GAuc1DsXXzf0G31iZhmmzPufM15QEquWSO4U3AjqSEPEzDrX6EVZtHcPWjM3whnXuGDws3IXJZ61g==
- References: <20190729134700.GO11632@calimero.vinschen.de> <ced2750a-0a52-1396-b6c1-f4228116bde7@cornell.edu> <20190729152327.GQ11632@calimero.vinschen.de> <20190729154049.GR11632@calimero.vinschen.de> <c5d01965-80b9-cece-54d2-f7462f84c0a2@cornell.edu> <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> <a61264b5-80da-52fc-7093-8e8d9a8ace33@redhat.com> <20190801160440.GC11632@calimero.vinschen.de> <19e73527-cb9a-a106-a57a-2895b8a520c9@cornell.edu> <e922144a-1f02-9398-4223-dbf76c69231f@cornell.edu>
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()?
Ken