X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmain.c;h=35cd7724c30d926276538aebea07a4b079e1f515;hb=d51539b182c0a8869e2063e82d04f8a5849bfbab;hp=05f0803b8bb81550a22d2050b426c89ec9d36e3b;hpb=db813c2a9199d694f8e97618889425a2401524d6;p=elogind.git diff --git a/src/core/main.c b/src/core/main.c index 05f0803b8..35cd7724c 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -116,7 +116,8 @@ _noreturn_ static void crash(int sig) { sa.sa_flags = SA_NOCLDSTOP|SA_RESTART; assert_se(sigaction(SIGCHLD, &sa, NULL) == 0); - if ((pid = fork()) < 0) + pid = fork(); + if (pid < 0) log_error("Caught <%s>, cannot fork for core dump: %s", signal_to_string(sig), strerror(errno)); else if (pid == 0) { @@ -147,7 +148,8 @@ _noreturn_ static void crash(int sig) { int r; /* Order things nicely. */ - if ((r = wait_for_terminate(pid, &status)) < 0) + r = wait_for_terminate(pid, &status); + if (r < 0) log_error("Caught <%s>, waitpid() failed: %s", signal_to_string(sig), strerror(-r)); else if (status.si_code != CLD_DUMPED) log_error("Caught <%s>, core dump failed.", signal_to_string(sig)); @@ -1573,10 +1575,9 @@ int main(int argc, char *argv[]) { /* Make sure we leave a core dump without panicing the * kernel. */ - if (getpid() == 1) + if (getpid() == 1) { install_crash_handler(); - if (getpid() == 1) { r = mount_cgroup_controllers(arg_join_controllers); if (r < 0) goto finish;