mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
Merge pull request #26479 from yuwata/exec-util-misc
exec-util: several cleanups
This commit is contained in:
commit
0ba75bde5f
@ -1185,7 +1185,7 @@ int safe_fork_full(
|
||||
else
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
return log_full_errno(prio, errno, "Failed to fork: %m");
|
||||
return log_full_errno(prio, errno, "Failed to fork off '%s': %m", strna(name));
|
||||
if (pid > 0) {
|
||||
/* We are in the parent process */
|
||||
|
||||
|
@ -151,18 +151,16 @@ static int do_execute(
|
||||
t = NULL;
|
||||
} else {
|
||||
r = wait_for_terminate_and_check(t, pid, WAIT_LOG);
|
||||
if (FLAGS_SET(flags, EXEC_DIR_IGNORE_ERRORS)) {
|
||||
if (r < 0)
|
||||
continue;
|
||||
} else if (r > 0)
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!FLAGS_SET(flags, EXEC_DIR_IGNORE_ERRORS) && r > 0)
|
||||
return r;
|
||||
|
||||
if (callbacks) {
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
return log_error_errno(errno, "Failed to seek on serialization fd: %m");
|
||||
|
||||
r = callbacks[STDOUT_GENERATE](fd, callback_args[STDOUT_GENERATE]);
|
||||
fd = -EBADF;
|
||||
r = callbacks[STDOUT_GENERATE](TAKE_FD(fd), callback_args[STDOUT_GENERATE]);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to process output from %s: %m", *path);
|
||||
}
|
||||
@ -186,6 +184,8 @@ static int do_execute(
|
||||
assert(t);
|
||||
|
||||
r = wait_for_terminate_and_check(t, pid, WAIT_LOG);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!FLAGS_SET(flags, EXEC_DIR_IGNORE_ERRORS) && r > 0)
|
||||
return r;
|
||||
}
|
||||
@ -249,8 +249,7 @@ int execute_directories(
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
return log_error_errno(errno, "Failed to rewind serialization fd: %m");
|
||||
|
||||
r = callbacks[STDOUT_CONSUME](fd, callback_args[STDOUT_CONSUME]);
|
||||
fd = -EBADF;
|
||||
r = callbacks[STDOUT_CONSUME](TAKE_FD(fd), callback_args[STDOUT_CONSUME]);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse returned data: %m");
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user