[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master b39f5e6: Don’t ignore stderr failure when ADDRESS_
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master b39f5e6: Don’t ignore stderr failure when ADDRESS_SANITIZER |
Date: |
Sat, 6 Jul 2019 20:43:17 -0400 (EDT) |
branch: master
commit b39f5e6c9c50b3153c4e7bfac9219f14da73e4d1
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
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.
---
src/emacs.c | 20 --------------------
src/sysdep.c | 20 ++++++++++++++++++++
src/sysstdio.h | 1 +
3 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/src/emacs.c b/src/emacs.c
index 32bb57e..fc1a4be 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -29,8 +29,6 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
#include <sys/stat.h>
#include <unistd.h>
-#include <close-stream.h>
-
#define MAIN_PROGRAM
#include "lisp.h"
#include "sysstdio.h"
@@ -661,24 +659,6 @@ argmatch (char **argv, int argc, const char *sstr, const
char *lstr,
}
}
-/* 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)
- {
- emacs_perror ("Write error to standard output");
- _exit (EXIT_FAILURE);
- }
-
- /* Do not close stderr if addresses are being sanitized, as the
- sanitizer might report to stderr after this function is
- invoked. */
- if (!ADDRESS_SANITIZER && close_stream (stderr) != 0)
- _exit (EXIT_FAILURE);
-}
-
#ifdef HAVE_PDUMPER
static const char *
diff --git a/src/sysdep.c b/src/sysdep.c
index 4f89e8a..48eebb5 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/>. */
#include <unistd.h>
#include <c-ctype.h>
+#include <close-stream.h>
#include <pathmax.h>
#include <utimens.h>
@@ -2768,6 +2769,25 @@ safe_strsignal (int code)
return signame;
}
+/* Close standard output and standard error, reporting any write
+ errors as best we can. This is intended for use with atexit. */
+void
+close_output_streams (void)
+{
+ if (close_stream (stdout) != 0)
+ {
+ emacs_perror ("Write error to standard output");
+ _exit (EXIT_FAILURE);
+ }
+
+ /* Do not close stderr if addresses are being sanitized, as the
+ sanitizer might report to stderr after this function is invoked. */
+ if (ADDRESS_SANITIZER
+ ? fflush_unlocked (stderr) != 0 || ferror (stderr)
+ : close_stream (stderr) != 0)
+ _exit (EXIT_FAILURE);
+}
+
#ifndef DOS_NT
/* For make-serial-process */
int
diff --git a/src/sysstdio.h b/src/sysstdio.h
index 3ff1d6a..a2364c4 100644
--- a/src/sysstdio.h
+++ b/src/sysstdio.h
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
#include <stdio.h>
extern FILE *emacs_fopen (char const *, char const *);
+extern void close_output_streams (void);
#if O_BINARY
# define FOPEN_BINARY "b"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master b39f5e6: Don’t ignore stderr failure when ADDRESS_SANITIZER,
Paul Eggert <=