diff options
| author | _ov4 <ov4@ov4.org> | 2026-09-14 09:03:31 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-09-14 09:03:31 +0000 |
| commit | 136d97f00528571906a11242d7b199dad7b6e493 (patch) | |
| tree | 27bcaec56006463a2e22b38f72a54136daaa57b3 /src | |
| parent | 02ea5f148ad2bdc7890de174366b8fd060e0559b (diff) | |
add exit code output
Diffstat (limited to 'src')
| -rw-r--r-- | src/handler.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/handler.cc b/src/handler.cc index 77512ec..5850141 100644 --- a/src/handler.cc +++ b/src/handler.cc @@ -69,6 +69,7 @@ void sigchld_handler([[maybe_unused]] int sig) while ((pid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) { + // signal'd or stopped or normally quit if (WIFSIGNALED(status) || WIFSTOPPED(status)) { int jid = pid2jid(pid); @@ -87,6 +88,7 @@ void sigchld_handler([[maybe_unused]] int sig) safe_print("\n"); } + // stopped if (WIFSTOPPED(status)) { // safe_debug("suspended pid: "); @@ -98,12 +100,21 @@ void sigchld_handler([[maybe_unused]] int sig) job_suspend(pid); sigprocmask(SIG_SETMASK, &prev_inner, nullptr); } + // other type of signal'd + // or normally quit else { safe_output("Process terminated PID: ", pid, "\n"); sigset_t prev_inner; block_all(&prev_inner); deletejob(pid); sigprocmask(SIG_SETMASK, &prev_inner, nullptr); + + // normally quit + // so that exit code should be available + if (WIFEXITED(status)) + { + safe_output("Exit code: ", WEXITSTATUS(status), "\n"); + } } } |
