#include <sys/file.h>
#include <unistd.h>
+#include <close-stream.h>
#include <ignore-value.h>
#include "lisp.h"
#endif /* DOUG_LEA_MALLOC */
+/* 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)
+ {
+ fprintf (stderr, "Write error to standard output: %s\n",
+ emacs_strerror (errno));
+ fflush (stderr);
+ _exit (EXIT_FAILURE);
+ }
+
+ if (close_stream (stderr) != 0)
+ _exit (EXIT_FAILURE);
+}
/* ARGSUSED */
int
if (do_initial_setlocale)
setlocale (LC_ALL, "");
+ atexit (close_output_streams);
+
inhibit_window_system = 0;
/* Handle the -t switch, which specifies filename to use as terminal. */
#endif /* DOS_NT */
}
+#if defined (HAVE_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
if (! noninteractive)
{
-#if defined (USG5) && defined (INTERRUPT_INPUT)
- setpgrp ();
-#endif
-#if defined (HAVE_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
- {
- extern void malloc_enable_thread (void);
+ extern void malloc_enable_thread (void);
- malloc_enable_thread ();
- }
-#endif
+ malloc_enable_thread ();
}
+#endif
init_signals (dumping);
exit_code = (XINT (arg) < 0
? XINT (arg) | INT_MIN
: XINT (arg) & INT_MAX);
- else if (noninteractive && (fflush (stdout) || ferror (stdout)))
- exit_code = EXIT_FAILURE;
else
exit_code = EXIT_SUCCESS;
exit (exit_code);