summaryrefslogtreecommitdiffstats
path: root/src/basic/exec-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-29 18:01:37 +0100
committerLennart Poettering <lennart@poettering.net>2018-01-04 13:27:27 +0100
commit1f5d1e02478fb550c926b23597895c7f1745dd9f (patch)
treedb93092f43f5a5ce7356bc6d9ab8faf013080879 /src/basic/exec-util.c
parentexec-util: drop redundant log message in do_spawn() (diff)
downloadsystemd-1f5d1e02478fb550c926b23597895c7f1745dd9f.tar.xz
systemd-1f5d1e02478fb550c926b23597895c7f1745dd9f.zip
process-spec: add another flag FORK_WAIT to safe_fork()
This new flag will cause safe_fork() to wait for the forked off child before returning. This allows us to unify a number of cases where we immediately wait on the forked off child, witout running any code in the parent after the fork, and without direct interest in the precise exit status of the process, except recgonizing EXIT_SUCCESS vs everything else.
Diffstat (limited to 'src/basic/exec-util.c')
-rw-r--r--src/basic/exec-util.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/basic/exec-util.c b/src/basic/exec-util.c
index 95194e5f05..a97295a509 100644
--- a/src/basic/exec-util.c
+++ b/src/basic/exec-util.c
@@ -189,10 +189,9 @@ int execute_directories(
void* const callback_args[_STDOUT_CONSUME_MAX],
char *argv[]) {
- pid_t executor_pid;
- char *name;
char **dirs = (char**) directories;
_cleanup_close_ int fd = -1;
+ char *name;
int r;
assert(!strv_isempty(dirs));
@@ -215,7 +214,7 @@ 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|FORK_LOG, &executor_pid);
+ r = safe_fork("(sd-executor)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_WAIT, NULL);
if (r < 0)
return r;
if (r == 0) {
@@ -223,12 +222,6 @@ int execute_directories(
_exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
- r = wait_for_terminate_and_check(name, executor_pid, WAIT_LOG);
- if (r < 0)
- return r;
- if (r > 0) /* non-zero return code from child */
- return -EREMOTEIO;
-
if (!callbacks)
return 0;