From: Markus Armbruster Date: Mon, 9 Mar 2009 20:10:44 +0000 (+0100) Subject: Fix crash dump not to mess up streams X-Git-Tag: v4.3.21~6 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=b510ee53458fd4ffe70ac26ce848057f64996f5a Fix crash dump not to mess up streams Crash dump forks a child to call abort(). abort() may flush or close streams. This is unwelcome, because it can mess up streams in the parent. Observed with the journal. Could theoretically also affect commands info, read, turn, and wire; announcement expiry, and reading of econfig and schedule. Fix by using SIGABRT instead. Note that flushing streams before fork() is not a sufficient fix, because closing a stream can still move the file descriptor's file position. Do it anyway, to ensure any buffered output is visible to post_crash_dump_hook. --- diff --git a/src/server/main.c b/src/server/main.c index 36d046e3f..b619fb208 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -324,13 +324,14 @@ crash_dump(void) pid_t pid; int status; + fflush(NULL); pid = fork(); if (pid < 0) { logerror("Can't fork for crash dump (%s)", strerror(errno)); return; } if (pid == 0) - abort(); /* child */ + raise(SIGABRT); /* child */ /* parent */ while (waitpid(pid, &status, 0) < 0) {