From b510ee53458fd4ffe70ac26ce848057f64996f5a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 9 Mar 2009 21:10:44 +0100 Subject: [PATCH] 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. --- src/server/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) { -- 2.43.0