From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juergen Nickelsen Newsgroups: gmane.emacs.bugs Subject: bug#16597: 23.2; Emacs's SIGPIPE ignore passed to child processes Date: Thu, 30 Jan 2014 17:44:35 +0100 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1391101094 31389 80.91.229.3 (30 Jan 2014 16:58:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 Jan 2014 16:58:14 +0000 (UTC) Cc: holger@cis.fu-berlin.de, plenz@zedat.fu-berlin.de, asulfrian@zedat.fu-berlin.de To: 16597@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 30 17:58:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W8uwU-0004s2-BM for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Jan 2014 17:58:18 +0100 Original-Received: from localhost ([::1]:51210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8uwU-0000mF-2M for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Jan 2014 11:58:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8uwM-0000jJ-2K for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2014 11:58:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8uwF-0007Mt-T4 for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2014 11:58:09 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55870) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8uwF-0007Mp-Px for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2014 11:58:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W8uwF-0008Og-DX for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2014 11:58:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juergen Nickelsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Jan 2014 16:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16597 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.139110102532195 (code B ref -1); Thu, 30 Jan 2014 16:58:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Jan 2014 16:57:05 +0000 Original-Received: from localhost ([127.0.0.1]:41656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8uvI-0008NC-KI for submit@debbugs.gnu.org; Thu, 30 Jan 2014 11:57:05 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:38285) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8ujZ-00084U-Dc for submit@debbugs.gnu.org; Thu, 30 Jan 2014 11:44:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8ujS-00024z-Uf for submit@debbugs.gnu.org; Thu, 30 Jan 2014 11:44:56 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:48168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ujS-00024v-S4 for submit@debbugs.gnu.org; Thu, 30 Jan 2014 11:44:50 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ujM-0004yt-TF for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2014 11:44:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8ujH-00022t-5Y for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2014 11:44:44 -0500 Original-Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]:46728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ujG-00022Q-S5 for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2014 11:44:39 -0500 Original-Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by outpost.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1W8ujE-001mGO-56>; Thu, 30 Jan 2014 17:44:36 +0100 Original-Received: from bermuda.zedat.fu-berlin.de ([130.133.10.14]) by relay1.zedat.fu-berlin.de (Exim 4.82) with esmtp (envelope-from ) id <1W8ujE-0000Gf-1y>; Thu, 30 Jan 2014 17:44:36 +0100 Original-Received: by bermuda.zedat.fu-berlin.de (Exim 4.82) with local (envelope-from ) id <1W8ujD-002x99-QZ>; Thu, 30 Jan 2014 17:44:35 +0100 X-Originating-IP: 130.133.10.14 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Mailman-Approved-At: Thu, 30 Jan 2014 11:57:02 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:84273 Archived-At: The problem: Emacs sets SIGPIPE handling to SIG_IGN, probably for good reasons. But this setting is also passed on to subprocesses, which can make some programs misbehave. I think it would be better to reset the SIGPIPE handling in the subprocess before calling the shell (or whatever). To reproduce: In a directory that contains the root of a git repository with a largish file (130295 bytes in this case) that is also checked in into the repository, I start "emacs -Q". In Emacs, I run the executable Perl script "./broken.pl" (contents below) as a shell command using M-! (shell-command): --------broken.pl---------------------------------------------------- #!/usr/bin/perl # demonstrate Emacs's SIGPIPE issue use Git; print("SIGPIPE: $SIG{PIPE}\n"); # $SIG{PIPE} = 'DEFAULT'; # print("SIGPIPE: $SIG{PIPE}\n"); my $content = Git::command_oneline(qw(show HEAD:largefile)); print("$content\n"); --------------------------------------------------------------------- The output is, as can also be seen below: SIGPIPE: IGNORE show HEAD:largefile: command returned error: 255 This does not happen with really small files instead of largefile, e.g. 1.5 KB. It also does not happen if the line with "$SIG{PIPE} = 'DEFAULT';" is reset, so the SIGPIPE is no longer ignored. Colleagues and I have pondered this for a while, and after examining some code and tracing the syscalls involved we have come up with the following explanation: The Perl Git library's function "command_oneline()" closes the pipe to its git subprocess after reading one line. If the file is short, it can be written into the pipe without fault, and the git process exit()s fast. If the file is large enough, the git subprocess would normally block on write() when the pipe is full and would finally be terminated by a SIGPIPE when the pipe is closed by the reader (the Perl process). But if SIGPIPE is set to SIG_IGN, the write() fails, and git exits with a non-zero exit status. This makes the Perl wrapper assume something went wrong (which it technically did), and it throws an exception. The issue can be worked around by (setq shell-command-switch "-ic") so the shell resets the signal handling, but that makes the shell complain about not being able to access its terminal's process group (small surprise!). Best regards, Juergen. *************** In GNU Emacs 23.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) of 2012-08-25 on trouble, modified by Debian Windowing system distributor `The X.Org Foundation', version 11.0.10707000 configured using `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.2/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS='' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: C value of $LC_CTYPE: de_DE@euro value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: C value of $XMODIFIERS: nil locale-coding-system: iso-latin-9-unix default enable-multibyte-characters: t Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: M-! . / b r o k e n . p l M-x r e p o r t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. SIGPIPE: IGNORE show HEAD:largefile: command returned error: 255 Load-path shadows: /usr/share/emacs/23.2/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode /usr/share/emacs/23.2/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup /usr/share/emacs/23.2/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/23.2/lisp/textmodes/flyspell /usr/share/emacs/23.2/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/23.2/lisp/textmodes/ispell Features: (shadow sort mail-extr message sendmail regexp-opt ecomplete rfc822 mml easymenu mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 hex-util hashcash mail-utils emacsbug tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs) -- Tel +49.30.838-50740 Fax -450740 Zentraleinrichtung fuer Datenverarbeitung, Central Systems (Unix) Freie Universitaet Berlin, Fabeckstrasse 32, 14195 Berlin, DE