aboutsummaryrefslogtreecommitdiffstats
path: root/src/supervision
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-04-27 18:35:28 +0000
committerLaurent Bercot <ska@appnovation.com>2025-04-27 18:35:28 +0000
commit7dda4a124069438acb19a419a088f5c1ab9b4670 (patch)
treea40ff60573c66f04c11087a32f3fd031e1926615 /src/supervision
parentd533300cb82ebb1d5e206e12961d044ac4f5ad1a (diff)
downloads6-7dda4a124069438acb19a419a088f5c1ab9b4670.tar.gz
pkg-config support, templated configure, etc.
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/supervision')
-rw-r--r--src/supervision/s6-supervise.c2
-rw-r--r--src/supervision/s6-svstat.c41
2 files changed, 26 insertions, 17 deletions
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c
index eeac5a0..bd8f4f9 100644
--- a/src/supervision/s6-supervise.c
+++ b/src/supervision/s6-supervise.c
@@ -834,7 +834,9 @@ int main (int argc, char const *const *argv)
settimeout(0) ;
tain_copynow(&status.stamp) ;
status.readystamp = status.stamp ;
+ status.flagpaused = 1 ;
announce() ;
+ status.flagpaused = 0 ;
ftrigw_notifyb_nosig(S6_SUPERVISE_EVENTDIR, "s", 1) ;
while (gflags.cont)
diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c
index 502991a..930570c 100644
--- a/src/supervision/s6-svstat.c
+++ b/src/supervision/s6-svstat.c
@@ -24,6 +24,9 @@
#define MAXFIELDS 16
#define checkfields() if (n >= MAXFIELDS) strerr_dief1x(100, "too many option fields")
+#define notstartedyet(st) (!(st)->pid && !(st)->flagfinishing && (st)->flagpaused)
+#define isup(st) ((st)->pid && !(st)->flagfinishing)
+
static int normallyup ;
typedef void pr_func (buffer *, s6_svstatus_t const *) ;
@@ -53,12 +56,12 @@ static void pr_ready (buffer *b, s6_svstatus_t const *st)
static void pr_paused (buffer *b, s6_svstatus_t const *st)
{
- buffer_putsnoflush(b, st->flagpaused ? "true" : "false") ;
+ buffer_putsnoflush(b, st->flagpaused && st->pid ? "true" : "false") ;
}
static void pr_pid (buffer *b, s6_svstatus_t const *st)
{
- if (st->pid && !st->flagfinishing)
+ if (isup(st) && !notstartedyet(st))
{
char fmt[PID_FMT] ;
buffer_putnoflush(b, fmt, pid_fmt(fmt, st->pid)) ;
@@ -112,7 +115,7 @@ static void pr_readyseconds (buffer *b, s6_svstatus_t const *st)
static void pr_exitcode (buffer *b, s6_svstatus_t const *st)
{
- int e = st->pid && !st->flagfinishing ? -1 :
+ int e = notstartedyet(st) || isup(st) ? -1 :
WIFEXITED(st->wstat) ? WEXITSTATUS(st->wstat) : -1 ;
char fmt[INT_FMT] ;
buffer_putnoflush(b, fmt, int_fmt(fmt, e)) ;
@@ -120,7 +123,7 @@ static void pr_exitcode (buffer *b, s6_svstatus_t const *st)
static void pr_signum (buffer *b, s6_svstatus_t const *st)
{
- int e = st->pid && !st->flagfinishing ? -1 :
+ int e = notstartedyet(st) || isup(st) ? -1 :
WIFSIGNALED(st->wstat) ? WTERMSIG(st->wstat) : -1 ;
char fmt[INT_FMT] ;
buffer_putnoflush(b, fmt, int_fmt(fmt, e)) ;
@@ -128,7 +131,7 @@ static void pr_signum (buffer *b, s6_svstatus_t const *st)
static void pr_signal (buffer *b, s6_svstatus_t const *st)
{
- int e = st->pid && !st->flagfinishing ? -1 :
+ int e = notstartedyet(st) || isup(st) ? -1 :
WIFSIGNALED(st->wstat) ? WTERMSIG(st->wstat) : -1 ;
if (e == -1) buffer_putsnoflush(b, "NA") ;
else
@@ -190,10 +193,9 @@ static unsigned int parse_options (char const *arg, pr_func_ref *fields, unsigne
static void legacy (s6_svstatus_t *st, int flagnum)
{
s6_svstatus_t status = *st ;
- int isup = status.pid && !status.flagfinishing ;
char fmt[UINT64_FMT] ;
- if (isup)
+ if (isup(st))
{
buffer_putnoflush(buffer_1small,"up (pid ", 8) ;
buffer_putnoflush(buffer_1small, fmt, pid_fmt(fmt, status.pid)) ;
@@ -204,7 +206,9 @@ static void legacy (s6_svstatus_t *st, int flagnum)
else
{
buffer_putnoflush(buffer_1small, "down (", 6) ;
- if (WIFSIGNALED(status.wstat))
+ if (notstartedyet(st))
+ buffer_putsnoflush(buffer_1small, "not started yet") ;
+ else if (WIFSIGNALED(status.wstat))
{
buffer_putnoflush(buffer_1small, "signal ", 7) ;
if (flagnum)
@@ -223,22 +227,25 @@ static void legacy (s6_svstatus_t *st, int flagnum)
buffer_putnoflush(buffer_1small, ") ", 2) ;
}
- tain_sub(&status.stamp, &STAMP, &status.stamp) ;
- buffer_putnoflush(buffer_1small, fmt, uint64_fmt(fmt, status.stamp.sec.x)) ;
- buffer_putnoflush(buffer_1small, " seconds", 8) ;
+ if (!notstartedyet(st))
+ {
+ tain_sub(&status.stamp, &STAMP, &status.stamp) ;
+ buffer_putnoflush(buffer_1small, fmt, uint64_fmt(fmt, status.stamp.sec.x)) ;
+ buffer_putnoflush(buffer_1small, " seconds", 8) ;
+ }
- if (isup && !normallyup)
+ if (isup(st) && !normallyup)
buffer_putnoflush(buffer_1small, ", normally down", 15) ;
- if (!isup && normallyup)
+ if (!isup(st) && normallyup)
buffer_putnoflush(buffer_1small, ", normally up", 13) ;
- if (isup && status.flagpaused)
+ if (isup(st) && status.flagpaused)
buffer_putnoflush(buffer_1small, ", paused", 8) ;
- if (!isup && status.flagwantup)
+ if (!isup(st) && status.flagwantup)
buffer_putnoflush(buffer_1small, ", want up", 9) ;
- if (isup && !status.flagwantup)
+ if (isup(st) && !status.flagwantup)
buffer_putnoflush(buffer_1small, ", want down", 11) ;
- if (status.flagready)
+ if (status.flagready && !notstartedyet(st))
{
tain_sub(&status.readystamp, &STAMP, &status.readystamp) ;
buffer_putnoflush(buffer_1small, ", ready ", 8) ;