From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 22 10:39:50 2011 Received: (at submit) by debbugs.gnu.org; 22 Sep 2011 14:39:50 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R6kRJ-0002oJ-J4 for submit@debbugs.gnu.org; Thu, 22 Sep 2011 10:39:50 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R6kRE-0002oA-W0 for submit@debbugs.gnu.org; Thu, 22 Sep 2011 10:39:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6kQm-0003yA-HJ for submit@debbugs.gnu.org; Thu, 22 Sep 2011 10:39:24 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:56815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6kQm-0003y6-Fw for submit@debbugs.gnu.org; Thu, 22 Sep 2011 10:39:16 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6kQh-0007Wr-IU for bug-gnu-emacs@gnu.org; Thu, 22 Sep 2011 10:39:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6kQg-0003xU-M5 for bug-gnu-emacs@gnu.org; Thu, 22 Sep 2011 10:39:11 -0400 Received: from fencepost.gnu.org ([140.186.70.10]:59990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6kQg-0003xQ-Ki for bug-gnu-emacs@gnu.org; Thu, 22 Sep 2011 10:39:10 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55934) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1R6kQg-0003NP-DN for bug-emacs@gnu.org; Thu, 22 Sep 2011 10:39:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6kQb-0003ww-P9 for bug-emacs@gnu.org; Thu, 22 Sep 2011 10:39:10 -0400 Received: from mx.meyering.net ([88.168.87.75]:56987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6kQb-0003ws-Ig for bug-emacs@gnu.org; Thu, 22 Sep 2011 10:39:05 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 9853960088 for ; Thu, 22 Sep 2011 16:39:04 +0200 (CEST) From: Jim Meyering To: bug-emacs@gnu.org Subject: data-loss with --batch: ignored write failure Date: Thu, 22 Sep 2011 16:39:04 +0200 Message-ID: <87mxdwd4l3.fsf@rho.meyering.net> Lines: 16 MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.6 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.8 (----) This should diagnose the write failure and exit nonzero: emacs --version > /dev/full Currently (latest from bzr trunk as of yesterday), emacs exits 0 (successfully) and gives no diagnostic. Obviously that doesn't matter too much, but this next one can easily cause real trouble: $ emacs --batch --eval '(print "important")' > /dev/full && echo FAIL FAIL I.e., the write fails and emacs fails to report that failure. That means anything written via --batch to standard output may be corrupted or incomplete, and emacs will still exit successfully. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 22 13:29:30 2011 Received: (at 9574) by debbugs.gnu.org; 22 Sep 2011 17:29:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R6n5W-0007Ly-8J for submit@debbugs.gnu.org; Thu, 22 Sep 2011 13:29:30 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R6n5S-0007Lq-8q for 9574@debbugs.gnu.org; Thu, 22 Sep 2011 13:29:27 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1R6n56-00020m-EG; Thu, 22 Sep 2011 13:29:04 -0400 From: Glenn Morris To: Jim Meyering Subject: Re: bug#9574: data-loss with --batch: ignored write failure References: <87mxdwd4l3.fsf@rho.meyering.net> X-Spook: South Africa CNCIS SAFE Majic kibo asset bemd event X-Ran: e,;GW4Fha7Xv?mRaOUN|iVn\r>>jizDUJ^)~m#t/R4aMWh&nJI*E|U'Z1Im>?AEt^Ce_/V X-Hue: white X-Debbugs-No-Ack: yes X-Attribution: GM Date: Thu, 22 Sep 2011 13:29:04 -0400 Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: 9574 Cc: 9574@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) Publicly shamed. :( http://www.gnu.org/ghm/2011/paris/slides/jim-meyering-goodbye-world.pdf ;) (All the way back to at least Emacs 21.1.) From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 23 05:59:16 2011 Received: (at 9574-done) by debbugs.gnu.org; 23 Sep 2011 09:59:16 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R72XL-000780-JV for submit@debbugs.gnu.org; Fri, 23 Sep 2011 05:59:16 -0400 Received: from mail-out.m-online.net ([212.18.0.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R72XI-00077q-Vc for 9574-done@debbugs.gnu.org; Fri, 23 Sep 2011 05:59:14 -0400 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 14B09188A198; Fri, 23 Sep 2011 11:58:46 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.8.164]) by mail.m-online.net (Postfix) with ESMTP id F27311C001EE; Fri, 23 Sep 2011 11:58:45 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.8.164]) (amavisd-new, port 10024) with ESMTP id l-01rCtARDwI; Fri, 23 Sep 2011 11:58:45 +0200 (CEST) Received: from igel.home (ppp-93-104-156-163.dynamic.mnet-online.de [93.104.156.163]) by mail.mnet-online.de (Postfix) with ESMTP; Fri, 23 Sep 2011 11:58:45 +0200 (CEST) Received: by igel.home (Postfix, from userid 501) id B3D25CA296; Fri, 23 Sep 2011 11:58:44 +0200 (CEST) From: Andreas Schwab To: Jim Meyering Subject: Re: bug#9574: data-loss with --batch: ignored write failure References: <87mxdwd4l3.fsf@rho.meyering.net> X-Yow: Quick, sing me the BUDAPEST NATIONAL ANTHEM!! Date: Fri, 23 Sep 2011 11:58:44 +0200 In-Reply-To: <87mxdwd4l3.fsf@rho.meyering.net> (Jim Meyering's message of "Thu, 22 Sep 2011 16:39:04 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9574-done Cc: 9574-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Fixed. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 23 14:30:41 2011 Received: (at 9574) by debbugs.gnu.org; 23 Sep 2011 18:30:41 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R7AWG-0004K9-1T for submit@debbugs.gnu.org; Fri, 23 Sep 2011 14:30:41 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R7AWC-0004K0-P9 for 9574@debbugs.gnu.org; Fri, 23 Sep 2011 14:30:37 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1R7AVj-0000go-8F; Fri, 23 Sep 2011 14:30:07 -0400 From: Glenn Morris To: 9574@debbugs.gnu.org Subject: Re: bug#9574: data-loss with --batch: ignored write failure References: <87mxdwd4l3.fsf@rho.meyering.net> X-Spook: MILSATCOM Israel ASPIC Manfurov Kosovo Dick Cheney SWAT X-Ran: $*^FCsJ?nNJek/C.>z@&ohoENS7=keKW+et-f!}68E%S/!-D,augd5-05t8*a"c&OpV$A~ X-Hue: cyan X-Debbugs-No-Ack: yes X-Attribution: GM Date: Fri, 23 Sep 2011 14:30:06 -0400 In-Reply-To: (Andreas Schwab's message of "Fri, 23 Sep 2011 11:58:44 +0200") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: 9574 Cc: schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) Andreas Schwab wrote: > Fixed. Not the --version part, FWIW. ./src/emacs -Q --version > /dev/full ; echo $? 0 ./src/emacs -Q --help > /dev/full ; echo $? 0 cf ls --version > /dev/full ; echo $? ls: write error: No space left on device 2 Also: ./src/emacs -Q --batch --eval '(print "important")' > /dev/full does indeed now return status 1, but no error message. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 24 05:24:01 2011 Received: (at 9574) by debbugs.gnu.org; 24 Sep 2011 09:24:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R7OSn-0000uh-4Z for submit@debbugs.gnu.org; Sat, 24 Sep 2011 05:24:01 -0400 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R7OSk-0000uZ-G1 for 9574@debbugs.gnu.org; Sat, 24 Sep 2011 05:23:59 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 70C3B60079 for <9574@debbugs.gnu.org>; Sat, 24 Sep 2011 11:23:26 +0200 (CEST) From: Jim Meyering To: 9574@debbugs.gnu.org Subject: Re: bug#9574: data-loss with --batch: ignored write failure In-Reply-To: (GNU bug Tracking System's message of "Fri, 23 Sep 2011 10:00:02 +0000") References: <87mxdwd4l3.fsf@rho.meyering.net> Date: Sat, 24 Sep 2011 11:23:26 +0200 Message-ID: <877h4yb8fl.fsf_-_@rho.meyering.net> Lines: 47 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 9574 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) > Subject: Re: bug#9574: data-loss with --batch: ignored write failure > > Fixed. Thanks, but even with your fix, emacs --batch would still ignore some write errors. I've just committed a change to fix that part properly. Included below. A clean fix for the entire problem (including --help and --version and anything else that may write to stdout) would be to ensure that no other code path explicitly closes stdout and to add this line in main: atexit (close_stdout); However, that would require gnulib's closeout module and would probably end up being too invasive a change to make during a code freeze. 2011-09-24 Jim Meyering do not ignore write error for any output size The previous change was incomplete. While it makes emacs --batch detect the vast majority of stdout write failures, errors were still ignored whenever the output size is k * (BUFSIZ+1) - 4. E.g., on a system with BUFSIZ of 4096, $ emacs --batch --eval '(print (format "%4093d" 0))' > /dev/full \ && echo FAIL: ignored write error FAIL: ignored write error $ emacs --batch --eval '(print (format "%20481d" 0))' > /dev/full \ && echo FAIL: ignored write error FAIL: ignored write error * emacs.c (Fkill_emacs): Also test ferror. (Bug#9574) === modified file 'src/emacs.c' --- src/emacs.c 2011-09-23 09:56:55 +0000 +++ src/emacs.c 2011-09-24 08:28:32 +0000 @@ -2019,7 +2019,7 @@ unlink (SSDATA (Vauto_save_list_file_name)); exit_code = EXIT_SUCCESS; - if (noninteractive && fflush (stdout)) + if (noninteractive && (fflush (stdout) || ferror (stdout))) exit_code = EXIT_FAILURE; exit (INTEGERP (arg) ? XINT (arg) : exit_code); } From unknown Fri Jun 20 07:12:48 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: Did not alter fixed versions and reopened. Date: Mon, 10 Oct 2011 00:22:02 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # Did not alter fixed versions and reopened. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 09 20:21:16 2011 Received: (at control) by debbugs.gnu.org; 10 Oct 2011 00:21:16 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RD3cK-0007Oj-AU for submit@debbugs.gnu.org; Sun, 09 Oct 2011 20:21:16 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RD3cI-0007Od-LC for control@debbugs.gnu.org; Sun, 09 Oct 2011 20:21:15 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1RD3cA-00068b-1d for control@debbugs.gnu.org; Sun, 09 Oct 2011 20:21:06 -0400 Date: Sun, 09 Oct 2011 20:21:06 -0400 Message-Id: Subject: control message for bug 9574 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) reopen 9574 severity 9574 minor tag 9574 pending From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 16 21:58:12 2012 Received: (at 9574) by debbugs.gnu.org; 17 Apr 2012 01:58:12 +0000 Received: from localhost ([127.0.0.1]:37545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SJxgK-0004aa-D7 for submit@debbugs.gnu.org; Mon, 16 Apr 2012 21:58:12 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:34638 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SJxgI-0004aT-KA for 9574@debbugs.gnu.org; Mon, 16 Apr 2012 21:58:11 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1SJxgB-0000y8-Rm; Mon, 16 Apr 2012 21:58:03 -0400 From: Glenn Morris To: Jim Meyering Subject: Re: bug#9574: data-loss with --batch: ignored write failure References: <87mxdwd4l3.fsf@rho.meyering.net> <877h4yb8fl.fsf_-_@rho.meyering.net> X-Spook: Medco interception broadside cryptographic top secret RSA X-Ran: Ts3'`kL@z'yU3xI;r1cN;?oWK'(VBw*iB#3Jl5JJI<-lB (Jim Meyering's message of "Sat, 24 Sep 2011 11:23:26 +0200") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 9574 Cc: Paul Eggert , 9574@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) Jim Meyering wrote: > A clean fix for the entire problem (including --help and --version and > anything else that may write to stdout) would be to ensure that no other > code path explicitly closes stdout and to add this line in main: > > atexit (close_stdout); > > However, that would require gnulib's closeout module and would probably > end up being too invasive a change to make during a code freeze. Such a change could probably be applied to the Emacs trunk now... (Cc'ing Paul since he has done most/all of the gnulib additions in Emacs.) From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 17 00:54:14 2012 Received: (at 9574) by debbugs.gnu.org; 17 Apr 2012 04:54:15 +0000 Received: from localhost ([127.0.0.1]:37635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SK0Qg-0000FN-6n for submit@debbugs.gnu.org; Tue, 17 Apr 2012 00:54:14 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:37734) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SK0Qc-0000F7-KO for 9574@debbugs.gnu.org; Tue, 17 Apr 2012 00:54:12 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 11B3739E800A; Mon, 16 Apr 2012 21:53:59 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O7XGpV3H8-FI; Mon, 16 Apr 2012 21:53:58 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 7C9AA39E8007; Mon, 16 Apr 2012 21:53:58 -0700 (PDT) Message-ID: <4F8CF760.30709@cs.ucla.edu> Date: Mon, 16 Apr 2012 21:53:52 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: Glenn Morris Subject: Re: bug#9574: data-loss with --batch: ignored write failure References: <87mxdwd4l3.fsf@rho.meyering.net> <877h4yb8fl.fsf_-_@rho.meyering.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 9574 Cc: Jim Meyering , 9574@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 04/16/2012 06:58 PM, Glenn Morris wrote: > Such a change could probably be applied to the Emacs trunk now... I wouldn't do that without syncing from gnulib (because I'd rather not debug cherry-picking changes from gnulib). That would be an automatic but pervasive change. Stefan has indicated that he doesn't want pervasive changes until after Emacs 24.1 is out, because it might make it harder to merge changes from the emacs-24 branch back into the trunk. > (Cc'ing Paul since he has done most/all of the gnulib additions in Emacs.) From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 05:30:22 2012 Received: (at 9574) by debbugs.gnu.org; 29 Oct 2012 09:30:22 +0000 Received: from localhost ([127.0.0.1]:37411 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSlfq-0001lN-6n for submit@debbugs.gnu.org; Mon, 29 Oct 2012 05:30:22 -0400 Received: from mail-pb0-f44.google.com ([209.85.160.44]:45440) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSlfn-0001hc-TH for 9574@debbugs.gnu.org; Mon, 29 Oct 2012 05:30:21 -0400 Received: by mail-pb0-f44.google.com with SMTP id ro8so3995661pbb.3 for <9574@debbugs.gnu.org>; Mon, 29 Oct 2012 02:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=mmBL7Z0wkArz2L20SPL4vM4TkZk4EpvKnZeW63L/uLI=; b=0oKVT4XzhLVA8vcnVi9luw0Pqt3irn4dWGTLP3SgLvAKvT44q0NyBgvDW6nDDAT+oI TAXjz7g0MFkbhqpZJNxkLctjsbFSh7I6KQAB7h6d5Nqyem4/jvlbKS1ZVuWf9xcFASKh s/rV4vdtBFvDppP8rbcIaGJKbWVACSuNW2QsTCW8vtpim0BSfyQqVjqL4rYVErr0QEUA BqUepllNxf272bdtmBaySDnZepTmFEbfeKkORDiqxhk8NRrXruL0o+zNezp8CVeGdsQa Lf+Et9u1iZUUbBb5kODncU6H8J0yBuXz97bunyUkLagmLQRJLoxpmbvMonsZpC+u2EA8 t1Vg== Received: by 10.69.1.1 with SMTP id bc1mr41522642pbd.102.1351502874253; Mon, 29 Oct 2012 02:27:54 -0700 (PDT) Received: from ulysses ([155.69.16.22]) by mx.google.com with ESMTPS id iq3sm5722397pbc.5.2012.10.29.02.27.50 (version=SSLv3 cipher=OTHER); Mon, 29 Oct 2012 02:27:53 -0700 (PDT) From: Chong Yidong To: Paul Eggert Subject: Re: bug#9574: data-loss with --batch: ignored write failure References: <87mxdwd4l3.fsf@rho.meyering.net> <877h4yb8fl.fsf_-_@rho.meyering.net> <4F8CF760.30709@cs.ucla.edu> Date: Mon, 29 Oct 2012 17:27:46 +0800 In-Reply-To: <4F8CF760.30709@cs.ucla.edu> (Paul Eggert's message of "Mon, 16 Apr 2012 21:53:52 -0700") Message-ID: <87ehkheigd.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 9574 Cc: Glenn Morris , 9574@debbugs.gnu.org, Jim Meyering X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.7 (/) Paul Eggert writes: > On 04/16/2012 06:58 PM, Glenn Morris wrote: >> Such a change could probably be applied to the Emacs trunk now... > > I wouldn't do that without syncing from gnulib (because I'd rather not > debug cherry-picking changes from gnulib). That would be an automatic > but pervasive change. Has this bug been fixed since the above was written 6 months ago? If so, please close it, thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 01 16:11:55 2012 Received: (at 9574) by debbugs.gnu.org; 1 Nov 2012 20:11:56 +0000 Received: from localhost ([127.0.0.1]:43467 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TU17K-0003jZ-GV for submit@debbugs.gnu.org; Thu, 01 Nov 2012 16:11:55 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:44344) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TU17G-0003jP-Hy for 9574@debbugs.gnu.org; Thu, 01 Nov 2012 16:11:53 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id CB75AA6001C; Thu, 1 Nov 2012 13:09:05 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lmqbMTO-Ecga; Thu, 1 Nov 2012 13:09:04 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 2F998A60001; Thu, 1 Nov 2012 13:09:04 -0700 (PDT) Message-ID: <5092D6DF.5070008@cs.ucla.edu> Date: Thu, 01 Nov 2012 13:09:03 -0700 From: Paul Eggert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 MIME-Version: 1.0 To: Chong Yidong Subject: Re: bug#9574: data-loss with --batch: ignored write failure References: <87mxdwd4l3.fsf@rho.meyering.net> <877h4yb8fl.fsf_-_@rho.meyering.net> <4F8CF760.30709@cs.ucla.edu> <87ehkheigd.fsf@gnu.org> In-Reply-To: <87ehkheigd.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -4.9 (----) X-Debbugs-Envelope-To: 9574 Cc: Glenn Morris , 9574@debbugs.gnu.org, Jim Meyering X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.9 (----) On 10/29/2012 02:27 AM, Chong Yidong wrote: > Has this bug been fixed since the above was written 6 months ago? Sorry, no. Here's a patch, relative to trunk bzr 110763. I won't install it right now, since we're so close to creating a branch. === modified file 'ChangeLog' --- ChangeLog 2012-10-26 18:35:36 +0000 +++ ChangeLog 2012-11-01 20:07:42 +0000 @@ -1,3 +1,11 @@ +2012-11-01 Paul Eggert + + Fix data-loss with --batch (Bug#9574). + * lib/close-stream.c, lib/close-stream.h, lib/fpending.c + * lib/fpending.h, m4/close-stream.m4, m4/fpending.m4: + New files, from gnulib. + * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. + 2012-10-26 Glenn Morris * Makefile.in (EMACS_NAME): New variable. === modified file 'admin/ChangeLog' --- admin/ChangeLog 2012-10-19 19:25:18 +0000 +++ admin/ChangeLog 2012-11-01 20:07:42 +0000 @@ -1,3 +1,8 @@ +2012-11-01 Paul Eggert + + Fix data-loss with --batch (Bug#9574). + * merge-gnulib (GNULIB_MODULES): Add close-stream. + 2012-10-12 Kenichi Handa * charsets/Makefile (JISC6226.map): Add missing mappings. === modified file 'admin/merge-gnulib' --- admin/merge-gnulib 2012-10-19 19:25:18 +0000 +++ admin/merge-gnulib 2012-11-01 20:07:42 +0000 @@ -27,7 +27,7 @@ GNULIB_MODULES=' alloca-opt c-ctype c-strcase - careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 + careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat === added file 'lib/close-stream.c' --- lib/close-stream.c 1970-01-01 00:00:00 +0000 +++ lib/close-stream.c 2012-11-01 20:07:42 +0000 @@ -0,0 +1,78 @@ +/* Close a stream, with nicer error checking than fclose's. + + Copyright (C) 1998-2002, 2004, 2006-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include "close-stream.h" + +#include +#include + +#include "fpending.h" + +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +#endif + +/* Close STREAM. Return 0 if successful, EOF (setting errno) + otherwise. A failure might set errno to 0 if the error number + cannot be determined. + + A failure with errno set to EPIPE may or may not indicate an error + situation worth signaling to the user. See the documentation of the + close_stdout_set_ignore_EPIPE function for details. + + If a program writes *anything* to STREAM, that program should close + STREAM and make sure that it succeeds before exiting. Otherwise, + suppose that you go to the extreme of checking the return status + of every function that does an explicit write to STREAM. The last + printf can succeed in writing to the internal stream buffer, and yet + the fclose(STREAM) could still fail (due e.g., to a disk full error) + when it tries to write out that buffered data. Thus, you would be + left with an incomplete output file and the offending program would + exit successfully. Even calling fflush is not always sufficient, + since some file systems (NFS and CODA) buffer written/flushed data + until an actual close call. + + Besides, it's wasteful to check the return value from every call + that writes to STREAM -- just let the internal stream state record + the failure. That's what the ferror test is checking below. */ + +int +close_stream (FILE *stream) +{ + const bool some_pending = (__fpending (stream) != 0); + const bool prev_fail = (ferror (stream) != 0); + const bool fclose_fail = (fclose (stream) != 0); + + /* Return an error indication if there was a previous failure or if + fclose failed, with one exception: ignore an fclose failure if + there was no previous error, no data remains to be flushed, and + fclose failed with EBADF. That can happen when a program like cp + is invoked like this 'cp a b >&-' (i.e., with standard output + closed) and doesn't generate any output (hence no previous error + and nothing to be flushed). */ + + if (prev_fail || (fclose_fail && (some_pending || errno != EBADF))) + { + if (! fclose_fail) + errno = 0; + return EOF; + } + + return 0; +} === added file 'lib/close-stream.h' --- lib/close-stream.h 1970-01-01 00:00:00 +0000 +++ lib/close-stream.h 2012-11-01 20:07:42 +0000 @@ -0,0 +1,2 @@ +#include +int close_stream (FILE *stream); === added file 'lib/fpending.c' --- lib/fpending.c 1970-01-01 00:00:00 +0000 +++ lib/fpending.c 2012-11-01 20:07:42 +0000 @@ -0,0 +1,30 @@ +/* fpending.c -- return the number of pending output bytes on a stream + Copyright (C) 2000, 2004, 2006-2007, 2009-2012 Free Software Foundation, + Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +#include + +#include "fpending.h" + +/* Return the number of pending (aka buffered, unflushed) + bytes on the stream, FP, that is open for writing. */ +size_t +__fpending (FILE *fp) +{ + return PENDING_OUTPUT_N_BYTES; +} === added file 'lib/fpending.h' --- lib/fpending.h 1970-01-01 00:00:00 +0000 +++ lib/fpending.h 2012-11-01 20:07:42 +0000 @@ -0,0 +1,30 @@ +/* Declare __fpending. + + Copyright (C) 2000, 2003, 2005-2006, 2009-2012 Free Software Foundation, + Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Written by Jim Meyering. */ + +#include +#include + +#if HAVE_DECL___FPENDING +# if HAVE_STDIO_EXT_H +# include +# endif +#else +size_t __fpending (FILE *); +#endif === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2012-10-19 19:25:18 +0000 +++ lib/gnulib.mk 2012-11-01 20:07:42 +0000 @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings MOSTLYCLEANFILES += core *.stackdump @@ -84,6 +84,14 @@ ## end gnulib module careadlinkat +## begin gnulib module close-stream + +libgnu_a_SOURCES += close-stream.c + +EXTRA_DIST += close-stream.h + +## end gnulib module close-stream + ## begin gnulib module crypto/md5 libgnu_a_SOURCES += md5.c @@ -183,6 +191,15 @@ ## end gnulib module filemode +## begin gnulib module fpending + + +EXTRA_DIST += fpending.c fpending.h + +EXTRA_libgnu_a_SOURCES += fpending.c + +## end gnulib module fpending + ## begin gnulib module getloadavg === added file 'm4/close-stream.m4' --- m4/close-stream.m4 1970-01-01 00:00:00 +0000 +++ m4/close-stream.m4 2012-11-01 20:07:42 +0000 @@ -0,0 +1,11 @@ +#serial 4 +dnl Copyright (C) 2006-2007, 2009-2012 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Prerequisites of lib/close-stream.c. +AC_DEFUN([gl_CLOSE_STREAM], +[ + : +]) === added file 'm4/fpending.m4' --- m4/fpending.m4 1970-01-01 00:00:00 +0000 +++ m4/fpending.m4 2012-11-01 20:07:42 +0000 @@ -0,0 +1,90 @@ +# serial 19 + +# Copyright (C) 2000-2001, 2004-2012 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering +dnl Using code from emacs, based on suggestions from Paul Eggert +dnl and Ulrich Drepper. + +dnl Find out how to determine the number of pending output bytes on a stream. +dnl glibc (2.1.93 and newer) and Solaris provide __fpending. On other systems, +dnl we have to grub around in the FILE struct. + +AC_DEFUN([gl_FUNC_FPENDING], +[ + AC_CHECK_HEADERS_ONCE([stdio_ext.h]) + AC_CHECK_FUNCS_ONCE([__fpending]) + fp_headers=' +# include +# if HAVE_STDIO_EXT_H +# include +# endif +' + AC_CHECK_DECLS([__fpending], , , $fp_headers) +]) + +AC_DEFUN([gl_PREREQ_FPENDING], +[ + AC_CACHE_CHECK( + [how to determine the number of pending output bytes on a stream], + ac_cv_sys_pending_output_n_bytes, + [ + for ac_expr in \ + \ + '# glibc2' \ + 'fp->_IO_write_ptr - fp->_IO_write_base' \ + \ + '# traditional Unix' \ + 'fp->_ptr - fp->_base' \ + \ + '# BSD' \ + 'fp->_p - fp->_bf._base' \ + \ + '# SCO, Unixware' \ + '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \ + \ + '# QNX' \ + '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \ + \ + '# old glibc?' \ + 'fp->__bufp - fp->__buffer' \ + \ + '# old glibc iostream?' \ + 'fp->_pptr - fp->_pbase' \ + \ + '# emx+gcc' \ + 'fp->_ptr - fp->_buffer' \ + \ + '# Minix' \ + 'fp->_ptr - fp->_buf' \ + \ + '# Plan9' \ + 'fp->wp - fp->buf' \ + \ + '# VMS' \ + '(*fp)->_ptr - (*fp)->_base' \ + \ + '# e.g., DGUX R4.11; the info is not available' \ + 1 \ + ; do + + # Skip each embedded comment. + case "$ac_expr" in '#'*) continue;; esac + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[FILE *fp = stdin; (void) ($ac_expr);]])], + [fp_done=yes] + ) + test "$fp_done" = yes && break + done + + ac_cv_sys_pending_output_n_bytes=$ac_expr + ] + ) + AC_DEFINE_UNQUOTED([PENDING_OUTPUT_N_BYTES], + $ac_cv_sys_pending_output_n_bytes, + [the number of pending output bytes on stream 'fp']) +]) === modified file 'm4/gnulib-comp.m4' --- m4/gnulib-comp.m4 2012-10-19 19:25:18 +0000 +++ m4/gnulib-comp.m4 2012-11-01 20:07:42 +0000 @@ -44,6 +44,7 @@ # Code from module c-strcase: # Code from module careadlinkat: # Code from module clock-time: + # Code from module close-stream: # Code from module crypto/md5: # Code from module crypto/sha1: # Code from module crypto/sha256: @@ -58,6 +59,7 @@ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) # Code from module extern-inline: # Code from module filemode: + # Code from module fpending: # Code from module getloadavg: # Code from module getopt-gnu: # Code from module getopt-posix: @@ -141,6 +143,8 @@ gl_FUNC_ALLOCA AC_CHECK_FUNCS_ONCE([readlinkat]) gl_CLOCK_TIME + gl_CLOSE_STREAM + gl_MODULE_INDICATOR([close-stream]) gl_MD5 gl_SHA1 gl_SHA256 @@ -157,6 +161,11 @@ gl_EXECINFO_H AC_REQUIRE([gl_EXTERN_INLINE]) gl_FILEMODE + gl_FUNC_FPENDING + if test $ac_cv_func___fpending = no; then + AC_LIBOBJ([fpending]) + gl_PREREQ_FPENDING + fi gl_GETLOADAVG if test $HAVE_GETLOADAVG = 0; then AC_LIBOBJ([getloadavg]) @@ -534,6 +543,8 @@ lib/c-strncasecmp.c lib/careadlinkat.c lib/careadlinkat.h + lib/close-stream.c + lib/close-stream.h lib/dosname.h lib/dtoastr.c lib/dtotimespec.c @@ -542,6 +553,8 @@ lib/execinfo.in.h lib/filemode.c lib/filemode.h + lib/fpending.c + lib/fpending.h lib/ftoastr.c lib/ftoastr.h lib/getloadavg.c @@ -609,12 +622,14 @@ m4/alloca.m4 m4/c-strtod.m4 m4/clock_time.m4 + m4/close-stream.m4 m4/dup2.m4 m4/environ.m4 m4/execinfo.m4 m4/extensions.m4 m4/extern-inline.m4 m4/filemode.m4 + m4/fpending.m4 m4/getloadavg.m4 m4/getopt.m4 m4/gettime.m4 === modified file 'src/ChangeLog' --- src/ChangeLog 2012-11-01 14:21:45 +0000 +++ src/ChangeLog 2012-11-01 20:07:42 +0000 @@ -1,3 +1,13 @@ +2012-11-01 Paul Eggert + + Fix data-loss with --batch (Bug#9574). + * emacs.c: Include . + (close_output_streams): New function. + (main): Pass it to atexit, so that Emacs closes stdout and stderr + and handles errors appropriately. + (Fkill_emacs): Don't worry about flushing, as close_output_stream + does that now. + 2012-11-01 Eli Zaretskii * w32proc.c (getpgrp, setpgid): New functions. (Bug#12776) === modified file 'src/emacs.c' --- src/emacs.c 2012-10-31 17:27:29 +0000 +++ src/emacs.c 2012-11-01 20:07:42 +0000 @@ -27,6 +27,7 @@ #include #include +#include #include #include "lisp.h" @@ -675,6 +676,22 @@ #endif /* DOUG_LEA_MALLOC */ +/* Close standard output and standard error, reporting any write + errors as best we can. This is intended for use with atexit. */ +static void +close_output_streams (void) +{ + if (close_stream (stdout) != 0) + { + fprintf (stderr, "Write error to standard output: %s\n", + emacs_strerror (errno)); + fflush (stderr); + _exit (EXIT_FAILURE); + } + + if (close_stream (stderr) != 0) + _exit (EXIT_FAILURE); +} /* ARGSUSED */ int @@ -890,6 +907,8 @@ if (do_initial_setlocale) setlocale (LC_ALL, ""); + atexit (close_output_streams); + inhibit_window_system = 0; /* Handle the -t switch, which specifies filename to use as terminal. */ @@ -1867,8 +1886,6 @@ exit_code = (XINT (arg) < 0 ? XINT (arg) | INT_MIN : XINT (arg) & INT_MAX); - else if (noninteractive && (fflush (stdout) || ferror (stdout))) - exit_code = EXIT_FAILURE; else exit_code = EXIT_SUCCESS; exit (exit_code); From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 01 16:12:41 2012 Received: (at control) by debbugs.gnu.org; 1 Nov 2012 20:12:41 +0000 Received: from localhost ([127.0.0.1]:43474 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TU184-0003l9-A6 for submit@debbugs.gnu.org; Thu, 01 Nov 2012 16:12:41 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:44395) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TU181-0003l2-TN for control@debbugs.gnu.org; Thu, 01 Nov 2012 16:12:38 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 48AF2A60008 for ; Thu, 1 Nov 2012 13:09:53 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xHRYRTn9kILF for ; Thu, 1 Nov 2012 13:09:53 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 0CD82A60001 for ; Thu, 1 Nov 2012 13:09:53 -0700 (PDT) Message-ID: <5092D710.8050403@cs.ucla.edu> Date: Thu, 01 Nov 2012 13:09:52 -0700 From: Paul Eggert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 MIME-Version: 1.0 To: GNU bug control Subject: 9574 has a patch now Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.2 (--) tags 9574 patch From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 04 12:22:10 2012 Received: (at 9574-done) by debbugs.gnu.org; 4 Nov 2012 17:22:10 +0000 Received: from localhost ([127.0.0.1]:49220 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TV3ti-0001cS-CM for submit@debbugs.gnu.org; Sun, 04 Nov 2012 12:22:10 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:45679) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TV3tg-0001cM-VG for 9574-done@debbugs.gnu.org; Sun, 04 Nov 2012 12:22:09 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id F025AA60004 for <9574-done@debbugs.gnu.org>; Sun, 4 Nov 2012 09:19:07 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tIn79zAzqYpU for <9574-done@debbugs.gnu.org>; Sun, 4 Nov 2012 09:19:07 -0800 (PST) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id A9DDBA60002 for <9574-done@debbugs.gnu.org>; Sun, 4 Nov 2012 09:19:07 -0800 (PST) Message-ID: <5096A38B.4010708@cs.ucla.edu> Date: Sun, 04 Nov 2012 09:19:07 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 MIME-Version: 1.0 To: 9574-done@debbugs.gnu.org Subject: patch installed Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 9574-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) I installed the patch for this into the Emacs trunk as bzr 110786 and am marking it as done. From unknown Fri Jun 20 07:12:48 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 03 Dec 2012 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator