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.
This commit is contained in:
parent
84008cf870
commit
b510ee5345
1 changed files with 2 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue