summaryrefslogtreecommitdiff
path: root/src/basic/exec-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-29 18:01:37 +0100
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:49:51 +0200
commitda33559d0bb19673cd487ed8ca8284e6c84971c1 (patch)
tree1201383d1ed38d7568f160dd4c09e93ff8f81742 /src/basic/exec-util.c
parent069824bd6c91476242902f7a21d27df11ce18aac (diff)
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 f3182d306..e195bf985 100644
--- a/src/basic/exec-util.c
+++ b/src/basic/exec-util.c
@@ -193,10 +193,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));
@@ -219,7 +218,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) {
@@ -227,12 +226,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;