GNU bug report logs - #9574
data-loss with --batch: ignored write failure

Previous Next

Package: emacs;

Reported by: Jim Meyering <jim <at> meyering.net>

Date: Thu, 22 Sep 2011 14:40:02 UTC

Severity: minor

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jim Meyering <jim <at> meyering.net>
To: 9574 <at> debbugs.gnu.org
Subject: bug#9574: data-loss with --batch: ignored write failure
Date: Sat, 24 Sep 2011 11:23:26 +0200
> 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  <meyering <at> redhat.com>

	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);
 }




This bug report was last modified 12 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.