diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-11-07 19:06:54 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2025-11-07 19:06:54 +0000 |
| commit | 43253d337ef7a0b74e482e8bf847cb7c12744da0 (patch) | |
| tree | b2e2e7289d7d99cc9ed87b9fdcf8cace4f7e7b05 /src/supervision | |
| parent | 1667855c0c05f26b378ed8a011336770485321e5 (diff) | |
| download | s6-43253d337ef7a0b74e482e8bf847cb7c12744da0.tar.gz | |
POSIX guarantees that pid == pgid for session leaders!
Diffstat (limited to 'src/supervision')
| -rw-r--r-- | src/supervision/s6-supervise.c | 31 | ||||
| -rw-r--r-- | src/supervision/s6-svstat.c | 16 |
2 files changed, 13 insertions, 34 deletions
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c index ca44fc8..50a739f 100644 --- a/src/supervision/s6-supervise.c +++ b/src/supervision/s6-supervise.c @@ -138,7 +138,6 @@ static inline int read_downsig (void) static void set_down_and_ready (char const *s, unsigned int n) { status.pid = 0 ; - status.pgid = 0 ; status.flagfinishing = 0 ; status.flagready = 1 ; state = DOWN ; @@ -163,7 +162,7 @@ static void bail (void) static void killI (void) { - if (status.pgid > 0) killpg(status.pgid, SIGINT) ; + killpg(status.pid, SIGINT) ; } static void sigint (void) @@ -267,27 +266,21 @@ static void killr (void) static void killP (void) { - if (status.pgid > 0) - { - killpg(status.pgid, SIGSTOP) ; - status.flagpaused = 1 ; - announce() ; - } + killpg(status.pid, SIGSTOP) ; + status.flagpaused = 1 ; + announce() ; } static void killC (void) { - if (status.pgid > 0) - { - killpg(status.pgid, SIGCONT) ; - status.flagpaused = 0 ; - announce() ; - } + killpg(status.pid, SIGCONT) ; + status.flagpaused = 0 ; + announce() ; } static void killK (void) { - if (status.pgid > 0) killpg(status.pgid, SIGKILL) ; + killpg(status.pid, SIGKILL) ; } static void trystart (void) @@ -388,9 +381,6 @@ static void trystart (void) fd_close(notifyp[1]) ; notifyfd = notifyp[0] ; } - status.pgid = getsid(status.pid) ; - if (status.pgid == -1) - strerr_warnwu1sys("getsid (process group control commands will have no effect)") ; settimeout_infinite() ; nextstart = tain_zero ; state = UP ; @@ -462,7 +452,7 @@ static int uplastup_z (void) char fmt0[UINT_FMT] ; char fmt1[UINT_FMT] ; char fmt2[PID_FMT] ; - char const *cargv[6] = { "finish", fmt0, fmt1, servicename, status.pgid > 0 ? fmt2 : "-1", 0 } ; + char const *cargv[6] = { "finish", fmt0, fmt1, servicename, fmt2, 0 } ; status.flagpaused = 0 ; status.flagready = 0 ; @@ -475,7 +465,7 @@ static int uplastup_z (void) } fmt0[uint_fmt(fmt0, WIFSIGNALED(status.wstat) ? 256 : WEXITSTATUS(status.wstat))] = 0 ; fmt1[uint_fmt(fmt1, WTERMSIG(status.wstat))] = 0 ; - if (status.pgid > 0) fmt2[pid_fmt(fmt2, status.pgid)] = 0 ; + fmt2[pid_fmt(fmt2, status.pid)] = 0 ; if (!read_uint("max-death-tally", &n)) n = 100 ; if (n > S6_MAX_DEATH_TALLY) n = S6_MAX_DEATH_TALLY ; @@ -509,7 +499,6 @@ static int uplastup_z (void) tain_add_g(&deadline, &tto) ; else settimeout_infinite() ; } - status.pgid = getpgid(status.pid) ; status.flagfinishing = 1 ; announce() ; ftrigw_notifyb_nosig(S6_SUPERVISE_EVENTDIR, "d", 1) ; diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c index 930570c..318e89c 100644 --- a/src/supervision/s6-svstat.c +++ b/src/supervision/s6-svstat.c @@ -69,16 +69,6 @@ static void pr_pid (buffer *b, s6_svstatus_t const *st) else buffer_putsnoflush(b, "-1") ; } -static void pr_pgid (buffer *b, s6_svstatus_t const *st) -{ - if (st->pgid > 0) - { - char fmt[PID_FMT] ; - buffer_putnoflush(b, fmt, pid_fmt(fmt, st->pgid)) ; - } - else buffer_putsnoflush(b, "-1") ; -} - static void pr_tain (buffer *b, tain const *a) { char fmt[TIMESTAMP] ; @@ -152,7 +142,7 @@ static funcmap_t const fmtable[] = { .s = "exitcode", .f = &pr_exitcode }, { .s = "normallyup", .f = &pr_normallyup }, { .s = "paused", .f = &pr_paused }, - { .s = "pgid", .f = &pr_pgid }, + { .s = "pgid", .f = &pr_pid }, { .s = "pid", .f = &pr_pid }, { .s = "ready", .f = &pr_ready }, { .s = "readyfor", .f = &pr_readyseconds }, @@ -200,7 +190,7 @@ static void legacy (s6_svstatus_t *st, int flagnum) buffer_putnoflush(buffer_1small,"up (pid ", 8) ; buffer_putnoflush(buffer_1small, fmt, pid_fmt(fmt, status.pid)) ; buffer_putnoflush(buffer_1small, " pgid ", 6) ; - buffer_putnoflush(buffer_1small, fmt, pid_fmt(fmt, status.pgid)) ; + buffer_putnoflush(buffer_1small, fmt, pid_fmt(fmt, status.pid)) ; buffer_putnoflush(buffer_1small, ") ", 2) ; } else @@ -277,7 +267,7 @@ int main (int argc, char const *const *argv) case 'N' : checkfields() ; fields[n++] = &pr_normallyup ; break ; case 'r' : checkfields() ; fields[n++] = &pr_ready ; break ; case 'p' : checkfields() ; fields[n++] = &pr_pid ; break ; - case 'g' : checkfields() ; fields[n++] = &pr_pgid ; break ; + case 'g' : checkfields() ; fields[n++] = &pr_pid ; break ; case 'e' : checkfields() ; fields[n++] = &pr_exitcode ; break ; case 's' : checkfields() ; fields[n++] = &pr_signal ; break ; case 't' : checkfields() ; fields[n++] = &pr_upseconds ; break ; |
