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) {
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));
/* 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;