* 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.
#include <sys/stat.h>
#include <unistd.h>
-#include <close-stream.h>
-
#define MAIN_PROGRAM
#include "lisp.h"
#include "sysstdio.h"
}
}
-/* 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 *
#include <unistd.h>
#include <c-ctype.h>
+#include <close-stream.h>
#include <pathmax.h>
#include <utimens.h>
return signame;
}
\f
+/* 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);
+}
+\f
#ifndef DOS_NT
/* For make-serial-process */
int
#include <stdio.h>
extern FILE *emacs_fopen (char const *, char const *);
+extern void close_output_streams (void);
#if O_BINARY
# define FOPEN_BINARY "b"