aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorPaul Eggert2019-07-06 17:41:52 -0700
committerPaul Eggert2019-07-06 17:43:11 -0700
commitb39f5e6c9c50b3153c4e7bfac9219f14da73e4d1 (patch)
tree46b8df94b009c3836a28917037b20c7ea31a3119 /src/sysdep.c
parent851535f58745dcfbc8798b3a34b4fea852f93a3e (diff)
downloademacs-b39f5e6c9c50b3153c4e7bfac9219f14da73e4d1.tar.gz
emacs-b39f5e6c9c50b3153c4e7bfac9219f14da73e4d1.zip
Don’t ignore stderr failure when ADDRESS_SANITIZER
* src/emacs.c (close_output_streams): Move from here ... * src/sysdep.c: ... to here, where it really belongs anyway. When ADDRESS_SANITIZER, fflush stderr and check for ferror, to catch stderr output errors even in this case.
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 4f89e8aba10..48eebb594f7 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -30,6 +30,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
30#include <unistd.h> 30#include <unistd.h>
31 31
32#include <c-ctype.h> 32#include <c-ctype.h>
33#include <close-stream.h>
33#include <pathmax.h> 34#include <pathmax.h>
34#include <utimens.h> 35#include <utimens.h>
35 36
@@ -2768,6 +2769,25 @@ safe_strsignal (int code)
2768 return signame; 2769 return signame;
2769} 2770}
2770 2771
2772/* Close standard output and standard error, reporting any write
2773 errors as best we can. This is intended for use with atexit. */
2774void
2775close_output_streams (void)
2776{
2777 if (close_stream (stdout) != 0)
2778 {
2779 emacs_perror ("Write error to standard output");
2780 _exit (EXIT_FAILURE);
2781 }
2782
2783 /* Do not close stderr if addresses are being sanitized, as the
2784 sanitizer might report to stderr after this function is invoked. */
2785 if (ADDRESS_SANITIZER
2786 ? fflush_unlocked (stderr) != 0 || ferror (stderr)
2787 : close_stream (stderr) != 0)
2788 _exit (EXIT_FAILURE);
2789}
2790
2771#ifndef DOS_NT 2791#ifndef DOS_NT
2772/* For make-serial-process */ 2792/* For make-serial-process */
2773int 2793int