diff options
| author | Paul Eggert | 2019-07-06 17:41:52 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-06 17:43:11 -0700 |
| commit | b39f5e6c9c50b3153c4e7bfac9219f14da73e4d1 (patch) | |
| tree | 46b8df94b009c3836a28917037b20c7ea31a3119 /src | |
| parent | 851535f58745dcfbc8798b3a34b4fea852f93a3e (diff) | |
| download | emacs-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')
| -rw-r--r-- | src/emacs.c | 20 | ||||
| -rw-r--r-- | src/sysdep.c | 20 | ||||
| -rw-r--r-- | src/sysstdio.h | 1 |
3 files changed, 21 insertions, 20 deletions
diff --git a/src/emacs.c b/src/emacs.c index 32bb57e2725..fc1a4beec50 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/>. */ | |||
| 29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
| 30 | #include <unistd.h> | 30 | #include <unistd.h> |
| 31 | 31 | ||
| 32 | #include <close-stream.h> | ||
| 33 | |||
| 34 | #define MAIN_PROGRAM | 32 | #define MAIN_PROGRAM |
| 35 | #include "lisp.h" | 33 | #include "lisp.h" |
| 36 | #include "sysstdio.h" | 34 | #include "sysstdio.h" |
| @@ -661,24 +659,6 @@ argmatch (char **argv, int argc, const char *sstr, const char *lstr, | |||
| 661 | } | 659 | } |
| 662 | } | 660 | } |
| 663 | 661 | ||
| 664 | /* Close standard output and standard error, reporting any write | ||
| 665 | errors as best we can. This is intended for use with atexit. */ | ||
| 666 | static void | ||
| 667 | close_output_streams (void) | ||
| 668 | { | ||
| 669 | if (close_stream (stdout) != 0) | ||
| 670 | { | ||
| 671 | emacs_perror ("Write error to standard output"); | ||
| 672 | _exit (EXIT_FAILURE); | ||
| 673 | } | ||
| 674 | |||
| 675 | /* Do not close stderr if addresses are being sanitized, as the | ||
| 676 | sanitizer might report to stderr after this function is | ||
| 677 | invoked. */ | ||
| 678 | if (!ADDRESS_SANITIZER && close_stream (stderr) != 0) | ||
| 679 | _exit (EXIT_FAILURE); | ||
| 680 | } | ||
| 681 | |||
| 682 | #ifdef HAVE_PDUMPER | 662 | #ifdef HAVE_PDUMPER |
| 683 | 663 | ||
| 684 | static const char * | 664 | static const char * |
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. */ | ||
| 2774 | void | ||
| 2775 | close_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 */ |
| 2773 | int | 2793 | int |
diff --git a/src/sysstdio.h b/src/sysstdio.h index 3ff1d6a572a..a2364c4e1fb 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/>. */ | |||
| 24 | #include <stdio.h> | 24 | #include <stdio.h> |
| 25 | 25 | ||
| 26 | extern FILE *emacs_fopen (char const *, char const *); | 26 | extern FILE *emacs_fopen (char const *, char const *); |
| 27 | extern void close_output_streams (void); | ||
| 27 | 28 | ||
| 28 | #if O_BINARY | 29 | #if O_BINARY |
| 29 | # define FOPEN_BINARY "b" | 30 | # define FOPEN_BINARY "b" |