diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-27 21:49:19 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-01-04 13:27:26 +0100 |
commit | b6e1fff13dbfc1623de41b78bc525f410fb59b91 (patch) | |
tree | b920f51ea393852d2776aecaa0701293df8903a6 /src | |
parent | raw-clone: beef up raw_clone() wrapper a bit (diff) | |
download | systemd-b6e1fff13dbfc1623de41b78bc525f410fb59b91.tar.gz systemd-b6e1fff13dbfc1623de41b78bc525f410fb59b91.tar.bz2 systemd-b6e1fff13dbfc1623de41b78bc525f410fb59b91.zip |
process-util: add another fork_safe() flag for enabling LOG_ERR/LOG_WARN logging
Diffstat (limited to 'src')
-rw-r--r-- | src/activate/activate.c | 4 | ||||
-rw-r--r-- | src/basic/exec-util.c | 8 | ||||
-rw-r--r-- | src/basic/process-util.c | 25 | ||||
-rw-r--r-- | src/basic/process-util.h | 1 | ||||
-rw-r--r-- | src/core/shutdown.c | 4 | ||||
-rw-r--r-- | src/core/umount.c | 8 | ||||
-rw-r--r-- | src/coredump/coredumpctl.c | 6 | ||||
-rw-r--r-- | src/delta/delta.c | 4 | ||||
-rw-r--r-- | src/fsck/fsck.c | 6 | ||||
-rw-r--r-- | src/import/import-common.c | 8 | ||||
-rw-r--r-- | src/import/pull-common.c | 4 | ||||
-rw-r--r-- | src/journal-remote/journal-remote.c | 4 | ||||
-rw-r--r-- | src/login/inhibit.c | 6 | ||||
-rw-r--r-- | src/nspawn/nspawn-setuid.c | 4 | ||||
-rw-r--r-- | src/partition/makefs.c | 4 | ||||
-rw-r--r-- | src/quotacheck/quotacheck.c | 6 | ||||
-rw-r--r-- | src/remount-fs/remount-fs.c | 6 | ||||
-rw-r--r-- | src/shared/pager.c | 8 | ||||
-rw-r--r-- | src/sulogin-shell/sulogin-shell.c | 4 | ||||
-rw-r--r-- | src/systemctl/systemctl.c | 12 | ||||
-rw-r--r-- | src/tty-ask-password-agent/tty-ask-password-agent.c | 4 | ||||
-rw-r--r-- | src/udev/udev-event.c | 6 | ||||
-rw-r--r-- | src/vconsole/vconsole-setup.c | 8 |
23 files changed, 70 insertions, 80 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c index 67067a8f3..c07dcb862 100644 --- a/src/activate/activate.c +++ b/src/activate/activate.c @@ -274,9 +274,9 @@ static int fork_and_exec_process(const char* child, char** argv, char **env, int if (!joined) return log_oom(); - r = safe_fork("(activate)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &child_pid); + r = safe_fork("(activate)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &child_pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { /* In the child */ exec_process(child, argv, env, fd, 1); diff --git a/src/basic/exec-util.c b/src/basic/exec-util.c index afad636db..45a699e42 100644 --- a/src/basic/exec-util.c +++ b/src/basic/exec-util.c @@ -55,9 +55,9 @@ static int do_spawn(const char *path, char *argv[], int stdout_fd, pid_t *pid) { return 0; } - r = safe_fork("(direxec)", FORK_DEATHSIG, &_pid); + r = safe_fork("(direxec)", FORK_DEATHSIG|FORK_LOG, &_pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { char *_argv[2]; @@ -216,9 +216,9 @@ int execute_directories( * them to finish. Optionally a timeout is applied. If a file with the same name * exists in more than one directory, the earliest one wins. */ - r = safe_fork("(sd-executor)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &executor_pid); + r = safe_fork("(sd-executor)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &executor_pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { r = do_execute(dirs, timeout, callbacks, callback_args, fd, argv); _exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS); diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 9a42ce34f..c155a35a3 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -1152,11 +1152,13 @@ int safe_fork_full( pid_t original_pid, pid; sigset_t saved_ss; bool block_signals; - int r; + int prio, r; /* A wrapper around fork(), that does a couple of important initializations in addition to mere forking. Always * returns the child's PID in *ret_pid. Returns == 0 in the child, and > 0 in the parent. */ + prio = flags & FORK_LOG ? LOG_ERR : LOG_DEBUG; + original_pid = getpid_cached(); block_signals = flags & (FORK_RESET_SIGNALS|FORK_DEATHSIG); @@ -1167,10 +1169,10 @@ int safe_fork_full( /* We temporarily block all signals, so that the new child has them blocked initially. This way, we can be sure * that SIGTERMs are not lost we might send to the child. */ if (sigfillset(&ss) < 0) - return log_debug_errno(errno, "Failed to reset signal set: %m"); + return log_full_errno(prio, errno, "Failed to reset signal set: %m"); if (sigprocmask(SIG_SETMASK, &ss, &saved_ss) < 0) - return log_debug_errno(errno, "Failed to reset signal mask: %m"); + return log_full_errno(prio, errno, "Failed to reset signal mask: %m"); } pid = fork(); @@ -1180,7 +1182,7 @@ int safe_fork_full( if (block_signals) /* undo what we did above */ (void) sigprocmask(SIG_SETMASK, &saved_ss, NULL); - return log_debug_errno(r, "Failed to fork: %m"); + return log_full_errno(prio, r, "Failed to fork: %m"); } if (pid > 0) { /* We are in the parent process */ @@ -1207,31 +1209,32 @@ int safe_fork_full( if (name) { r = rename_process(name); if (r < 0) - log_debug_errno(r, "Failed to rename process, ignoring: %m"); + log_full_errno(flags & FORK_LOG ? LOG_WARNING : LOG_DEBUG, + r, "Failed to rename process, ignoring: %m"); } if (flags & FORK_DEATHSIG) if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0) { - log_debug_errno(errno, "Failed to set death signal: %m"); + log_full_errno(prio, errno, "Failed to set death signal: %m"); _exit(EXIT_FAILURE); } if (flags & FORK_RESET_SIGNALS) { r = reset_all_signal_handlers(); if (r < 0) { - log_debug_errno(r, "Failed to reset signal handlers: %m"); + log_full_errno(prio, r, "Failed to reset signal handlers: %m"); _exit(EXIT_FAILURE); } /* This implicitly undoes the signal mask stuff we did before the fork()ing above */ r = reset_signal_mask(); if (r < 0) { - log_debug_errno(r, "Failed to reset signal mask: %m"); + log_full_errno(prio, r, "Failed to reset signal mask: %m"); _exit(EXIT_FAILURE); } } else if (block_signals) { /* undo what we did above */ if (sigprocmask(SIG_SETMASK, &saved_ss, NULL) < 0) { - log_debug_errno(errno, "Failed to restore signal mask: %m"); + log_full_errno(prio, errno, "Failed to restore signal mask: %m"); _exit(EXIT_FAILURE); } } @@ -1257,7 +1260,7 @@ int safe_fork_full( r = close_all_fds(except_fds, n_except_fds); if (r < 0) { - log_debug_errno(r, "Failed to close all file descriptors: %m"); + log_full_errno(prio, r, "Failed to close all file descriptors: %m"); _exit(EXIT_FAILURE); } } @@ -1271,7 +1274,7 @@ int safe_fork_full( if (flags & FORK_NULL_STDIO) { r = make_null_stdio(); if (r < 0) { - log_debug_errno(r, "Failed to connect stdin/stdout to /dev/null: %m"); + log_full_errno(prio, r, "Failed to connect stdin/stdout to /dev/null: %m"); _exit(EXIT_FAILURE); } } diff --git a/src/basic/process-util.h b/src/basic/process-util.h index fa58c6946..ef3269d94 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -157,6 +157,7 @@ typedef enum ForkFlags { FORK_DEATHSIG = 1U << 2, FORK_NULL_STDIO = 1U << 3, FORK_REOPEN_LOG = 1U << 4, + FORK_LOG = 1U << 5, } ForkFlags; int safe_fork_full(const char *name, const int except_fds[], size_t n_except_fds, ForkFlags flags, pid_t *ret_pid); diff --git a/src/core/shutdown.c b/src/core/shutdown.c index efcc26403..440cb4fba 100644 --- a/src/core/shutdown.c +++ b/src/core/shutdown.c @@ -487,9 +487,7 @@ int main(int argc, char *argv[]) { log_info("Rebooting with kexec."); - r = safe_fork("(sd-kexec)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS, &pid); - if (r < 0) - log_error_errno(r, "Failed to fork: %m"); + r = safe_fork("(sd-kexec)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); if (r == 0) { const char * const args[] = { diff --git a/src/core/umount.c b/src/core/umount.c index b39181639..6b0100fb4 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -389,9 +389,9 @@ static int remount_with_timeout(MountPoint *m, char *options, int *n_failed) { * fork a child process and set a timeout. If the timeout * lapses, the assumption is that that particular remount * failed. */ - r = safe_fork("(sd-remount)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS, &pid); + r = safe_fork("(sd-remount)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { log_info("Remounting '%s' read-only in with options '%s'.", m->path, options); @@ -423,9 +423,9 @@ static int umount_with_timeout(MountPoint *m, bool *changed) { * fork a child process and set a timeout. If the timeout * lapses, the assumption is that that particular umount * failed. */ - r = safe_fork("(sd-umount)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS, &pid); + r = safe_fork("(sd-umount)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { log_info("Unmounting '%s'.", m->path); diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index a3f86aa55..4524d604b 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -928,11 +928,9 @@ static int run_gdb(sd_journal *j) { /* Don't interfere with gdb and its handling of SIGINT. */ (void) ignore_signals(SIGINT, -1); - r = safe_fork("(gdb)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS, &pid); - if (r < 0) { - log_error_errno(r, "Failed to fork(): %m"); + r = safe_fork("(gdb)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); + if (r < 0) goto finish; - } if (r == 0) { execlp("gdb", "gdb", exe, path, NULL); log_error_errno(errno, "Failed to invoke gdb: %m"); diff --git a/src/delta/delta.c b/src/delta/delta.c index 8ebfbf441..779dec6cb 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -186,9 +186,9 @@ static int found_override(const char *top, const char *bottom) { fflush(stdout); - r = safe_fork("(diff)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS, &pid); + r = safe_fork("(diff)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); if (r < 0) - return log_error_errno(pid, "Failed to fork off diff: %m"); + return r; if (r == 0) { execlp("diff", "diff", "-us", "--", bottom, top, NULL); log_error_errno(errno, "Failed to execute diff: %m"); diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 818d581c3..d2b7cf6e3 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -392,11 +392,9 @@ int main(int argc, char *argv[]) { } } - r = safe_fork("(fsck)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); - if (r < 0) { - log_error_errno(r, "fork(): %m"); + r = safe_fork("(fsck)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); + if (r < 0) goto finish; - } if (r == 0) { char dash_c[STRLEN("-C") + DECIMAL_STR_MAX(int) + 1]; int progress_socket = -1; diff --git a/src/import/import-common.c b/src/import/import-common.c index 1efbda978..aa7ab974d 100644 --- a/src/import/import-common.c +++ b/src/import/import-common.c @@ -82,9 +82,9 @@ int import_fork_tar_x(const char *path, pid_t *ret) { if (pipe2(pipefd, O_CLOEXEC) < 0) return log_error_errno(errno, "Failed to create pipe for tar: %m"); - r = safe_fork("(tar)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + r = safe_fork("(tar)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork off tar: %m"); + return r; if (r == 0) { int null_fd; uint64_t retain = @@ -151,9 +151,9 @@ int import_fork_tar_c(const char *path, pid_t *ret) { if (pipe2(pipefd, O_CLOEXEC) < 0) return log_error_errno(errno, "Failed to create pipe for tar: %m"); - r = safe_fork("(tar)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + r = safe_fork("(tar)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork off tar: %m"); + return r; if (r == 0) { int null_fd; uint64_t retain = (1ULL << CAP_DAC_OVERRIDE); diff --git a/src/import/pull-common.c b/src/import/pull-common.c index 6acd264af..593847f88 100644 --- a/src/import/pull-common.c +++ b/src/import/pull-common.c @@ -463,9 +463,9 @@ int pull_verify(PullJob *main_job, gpg_home_created = true; - r = safe_fork("(gpg)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + r = safe_fork("(gpg)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork off gpg: %m"); + return r; if (r == 0) { const char *cmd[] = { "gpg", diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 32416493f..a8755751e 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -87,10 +87,10 @@ static int spawn_child(const char* child, char** argv) { if (pipe(fd) < 0) return log_error_errno(errno, "Failed to create pager pipe: %m"); - r = safe_fork("(remote)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &child_pid); + r = safe_fork("(remote)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &child_pid); if (r < 0) { safe_close_pair(fd); - return log_error_errno(r, "Failed to fork: %m"); + return r; } /* In the child */ diff --git a/src/login/inhibit.c b/src/login/inhibit.c index 9117a7048..a197464b7 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -266,11 +266,9 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - r = safe_fork("(inhibit)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS, &pid); - if (r < 0) { - log_error_errno(r, "Failed to fork: %m"); + r = safe_fork("(inhibit)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); + if (r < 0) return EXIT_FAILURE; - } if (r == 0) { /* Child */ execvp(argv[optind], argv + optind); diff --git a/src/nspawn/nspawn-setuid.c b/src/nspawn/nspawn-setuid.c index 3d9e23ec1..b1d03d2d9 100644 --- a/src/nspawn/nspawn-setuid.c +++ b/src/nspawn/nspawn-setuid.c @@ -43,9 +43,9 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) { if (pipe2(pipe_fds, O_CLOEXEC) < 0) return log_error_errno(errno, "Failed to allocate pipe: %m"); - r = safe_fork("(getent)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + r = safe_fork("(getent)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork getent child: %m"); + return r; if (r == 0) { int nullfd; char *empty_env = NULL; diff --git a/src/partition/makefs.c b/src/partition/makefs.c index 872cf0dfd..df932fd35 100644 --- a/src/partition/makefs.c +++ b/src/partition/makefs.c @@ -43,9 +43,9 @@ static int makefs(const char *type, const char *device) { if (access(mkfs, X_OK) != 0) return log_error_errno(errno, "%s is not executable: %m", mkfs); - r = safe_fork("(fsck)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + r = safe_fork("(fsck)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "fork(): %m"); + return r; if (r == 0) { const char *cmdline[3] = { mkfs, device, NULL }; diff --git a/src/quotacheck/quotacheck.c b/src/quotacheck/quotacheck.c index cd441675d..2773e4b58 100644 --- a/src/quotacheck/quotacheck.c +++ b/src/quotacheck/quotacheck.c @@ -106,11 +106,9 @@ int main(int argc, char *argv[]) { return EXIT_SUCCESS; } - r = safe_fork("(quotacheck)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); - if (r < 0) { - log_error_errno(r, "fork(): %m"); + r = safe_fork("(quotacheck)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); + if (r < 0) goto finish; - } if (r == 0) { /* Child */ diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c index 1f0397cf6..c61777c3f 100644 --- a/src/remount-fs/remount-fs.c +++ b/src/remount-fs/remount-fs.c @@ -87,11 +87,9 @@ int main(int argc, char *argv[]) { log_debug("Remounting %s", me->mnt_dir); - r = safe_fork("(remount)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); - if (r < 0) { - log_error_errno(r, "Failed to fork: %m"); + r = safe_fork("(remount)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); + if (r < 0) goto finish; - } if (r == 0) { /* Child */ diff --git a/src/shared/pager.c b/src/shared/pager.c index 17e0121a6..a39abfda7 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -89,9 +89,9 @@ int pager_open(bool no_pager, bool jump_to_end) { if (pipe2(fd, O_CLOEXEC) < 0) return log_error_errno(errno, "Failed to create pager pipe: %m"); - r = safe_fork("(pager)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pager_pid); + r = safe_fork("(pager)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pager_pid); if (r < 0) - return log_error_errno(r, "Failed to fork pager: %m"); + return r; if (r == 0) { const char* less_opts, *less_charset; @@ -208,9 +208,9 @@ int show_man_page(const char *desc, bool null_stdio) { } else args[1] = desc; - r = safe_fork("(man)", FORK_RESET_SIGNALS|FORK_DEATHSIG|(null_stdio ? FORK_NULL_STDIO : 0), &pid); + r = safe_fork("(man)", FORK_RESET_SIGNALS|FORK_DEATHSIG|(null_stdio ? FORK_NULL_STDIO : 0)|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { /* Child */ execvp(args[0], (char**) args); diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c index a6e0e0476..e8839eae1 100644 --- a/src/sulogin-shell/sulogin-shell.c +++ b/src/sulogin-shell/sulogin-shell.c @@ -83,9 +83,9 @@ static int fork_wait(const char* const cmdline[]) { pid_t pid; int r; - r = safe_fork("(sulogin)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + r = safe_fork("(sulogin)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "fork(): %m"); + return r; if (r == 0) { /* Child */ execv(cmdline[0], (char**) cmdline); diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 61ce1d029..f97998836 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -3539,9 +3539,9 @@ static int load_kexec_kernel(void) { if (arg_dry_run) return 0; - r = safe_fork("(kexec)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + r = safe_fork("(kexec)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { const char* const args[] = { @@ -6119,9 +6119,9 @@ static int enable_sysv_units(const char *verb, char **args) { if (!arg_quiet) log_info("Executing: %s", l); - j = safe_fork("(sysv)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + j = safe_fork("(sysv)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (j < 0) - return log_error_errno(j, "Failed to fork: %m"); + return j; if (j == 0) { /* Child */ execv(argv[0], (char**) argv); @@ -6992,9 +6992,9 @@ static int run_editor(char **paths) { assert(paths); - r = safe_fork("(editor)", FORK_RESET_SIGNALS|FORK_DEATHSIG, &pid); + r = safe_fork("(editor)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { const char **args; char *editor, **editor_args = NULL; diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index 8edd891c8..6e9c10aeb 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -709,9 +709,9 @@ static int ask_on_this_console(const char *tty, pid_t *ret_pid, int argc, char * sig.sa_handler = SIG_DFL; assert_se(sigaction(SIGHUP, &sig, NULL) >= 0); - r = safe_fork("(sd-passwd)", FORK_RESET_SIGNALS, &pid); + r = safe_fork("(sd-passwd)", FORK_RESET_SIGNALS|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork process: %m"); + return r; if (r == 0) { int ac; diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 8506e67d6..d0befba29 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -774,11 +774,9 @@ int udev_event_spawn(struct udev_event *event, } } - err = safe_fork("(spawn)", FORK_RESET_SIGNALS, &pid); - if (err < 0) { - log_error_errno(err, "fork of '%s' failed: %m", cmd); + err = safe_fork("(spawn)", FORK_RESET_SIGNALS|FORK_LOG, &pid); + if (err < 0) goto out; - } if (err == 0) { char arg[UTIL_PATH_SIZE]; char *argv[128]; diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c index 60e23959a..7685f1d71 100644 --- a/src/vconsole/vconsole-setup.c +++ b/src/vconsole/vconsole-setup.c @@ -153,9 +153,9 @@ static int keyboard_load_and_wait(const char *vc, const char *map, const char *m log_debug("Executing \"%s\"...", strnull((cmd = strv_join((char**) args, " ")))); - r = safe_fork("(loadkeys)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS, &pid); + r = safe_fork("(loadkeys)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { execv(args[0], (char **) args); _exit(EXIT_FAILURE); @@ -193,9 +193,9 @@ static int font_load_and_wait(const char *vc, const char *font, const char *map, log_debug("Executing \"%s\"...", strnull((cmd = strv_join((char**) args, " ")))); - r = safe_fork("(setfont)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS, &pid); + r = safe_fork("(setfont)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); if (r < 0) - return log_error_errno(r, "Failed to fork: %m"); + return r; if (r == 0) { execv(args[0], (char **) args); _exit(EXIT_FAILURE); |