diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-03-16 11:34:14 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-03-17 20:38:15 +0900 |
commit | 6ad9af0b1356ac52db36a21088b553e8eeb9b396 (patch) | |
tree | 7deac1a4aa5e588a5239ff6afa253fad5bf02481 /src/shared/exec-util.c | |
parent | f691157b87371266d0cab1b9e67a3bc3808ce30f (diff) | |
download | systemd-6ad9af0b1356ac52db36a21088b553e8eeb9b396.tar.gz |
exec-util: introduce EXEC_DIR_SKIP_REMAINING flag
Will be used in later commits.
Diffstat (limited to 'src/shared/exec-util.c')
-rw-r--r-- | src/shared/exec-util.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index 29f8381883..ac68cbc4cb 100644 --- a/src/shared/exec-util.c +++ b/src/shared/exec-util.c @@ -30,6 +30,8 @@ #include "terminal-util.h" #include "tmpfile-util.h" +#define EXIT_SKIP_REMAINING 77 + /* Put this test here for a lack of better place */ assert_cc(EAGAIN == EWOULDBLOCK); @@ -145,11 +147,22 @@ static int do_execute( return log_oom(); t = NULL; } else { - r = wait_for_terminate_and_check(t, pid, WAIT_LOG); + bool skip_remaining = false; + + r = wait_for_terminate_and_check(t, pid, WAIT_LOG_ABNORMAL); if (r < 0) return r; - if (!FLAGS_SET(flags, EXEC_DIR_IGNORE_ERRORS) && r > 0) - return r; + if (r > 0) { + if (FLAGS_SET(flags, EXEC_DIR_SKIP_REMAINING) && r == EXIT_SKIP_REMAINING) { + log_info("%s succeeded with exit status %i, not executing remaining executables.", *path, r); + skip_remaining = true; + } else if (FLAGS_SET(flags, EXEC_DIR_IGNORE_ERRORS)) + log_warning("%s failed with exit status %i, ignoring.", *path, r); + else { + log_error("%s failed with exit status %i.", *path, r); + return r; + } + } if (callbacks) { if (lseek(fd, 0, SEEK_SET) < 0) @@ -159,6 +172,9 @@ static int do_execute( if (r < 0) return log_error_errno(r, "Failed to process output from %s: %m", *path); } + + if (skip_remaining) + break; } } @@ -202,6 +218,8 @@ int execute_strv( pid_t executor_pid; int r; + assert(!FLAGS_SET(flags, EXEC_DIR_PARALLEL | EXEC_DIR_SKIP_REMAINING)); + if (strv_isempty(paths)) return 0; |