From 0f8a6ff0ed7c57c636b79d8a7a9a78da837d763a Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Thu, 28 Jul 2005 03:34:44 +0000 Subject: Add a config option for abort() to shutdown the stdio subsystem. This is mainly to cut down on noise in the NIST/PCTS tests since older POSIX behavior was to fclose() (and hence fflush()) all open streams. --- libc/stdlib/abort.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libc') diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c index 05d7a6836..77c2cdc69 100644 --- a/libc/stdlib/abort.c +++ b/libc/stdlib/abort.c @@ -63,6 +63,9 @@ Cambridge, MA 02139, USA. */ #warning no abort instruction define for your arch #endif +#ifdef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__ +extern void weak_function _stdio_term(void); +#endif extern void _exit __P((int __status)) __attribute__ ((__noreturn__)); static int been_there_done_that = 0; @@ -95,6 +98,17 @@ void abort(void) /* Try to suicide with a SIGABRT */ if (been_there_done_that == 0) { been_there_done_that++; + +#ifdef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__ + /* If we are using stdio, try to shut it down. At the very least, + * this will attemt to commit all buffered writes. It may also + * unboffer all writable files, or close them outright. + * Check the stdio routines for details. */ + if (_stdio_term) { + _stdio_term(); + } +#endif + abort_it: UNLOCK; raise(SIGABRT); -- cgit v1.2.3