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.
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) {