bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Jim Meyering
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@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);
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]