diff options
author | Gerrit Pape <pape@smarden.org> | 2007-09-13 13:16:21 +0000 |
---|---|---|
committer | Gerrit Pape <pape@smarden.org> | 2007-09-13 13:38:12 +0000 |
commit | 6ea9716f1fc13a976aad8af0ed3138c9bc6333d5 (patch) | |
tree | be6efbf96c3a7d4d0ed6d7d6b188b6fe0511c5ab | |
parent | f2ae55e8662d9a71e127da637584dff415c07e9f (diff) | |
download | runit-6ea9716f1fc13a976aad8af0ed3138c9bc6333d5.tar.gz runit-6ea9716f1fc13a976aad8af0ed3138c9bc6333d5.tar.xz runit-6ea9716f1fc13a976aad8af0ed3138c9bc6333d5.zip |
sv.c: fix race on check for down if pid is 0 and state is run or finish.
-rw-r--r-- | package/CHANGES | 1 | ||||
-rw-r--r-- | src/sv.c | 15 |
2 files changed, 8 insertions, 8 deletions
diff --git a/package/CHANGES b/package/CHANGES index 3ad6f83..f30fee5 100644 --- a/package/CHANGES +++ b/package/CHANGES @@ -13,6 +13,7 @@ * chpst.c: add explicit braces to avoid ambiguous 'else'. * uw_tmp.h1: fallback to UTMP_FILE if _PATH_UTMP is not defined as seen on AIX 5.2 ML1, AIX 5.3 ML5 (thx Daniel Clark). + * sv.c: fix race on check for down if pid is 0 and state is run or finish. 1.7.2 Tue, 21 Nov 2006 15:13:47 +0000 diff --git a/src/sv.c b/src/sv.c index c8126a3..738a471 100644 --- a/src/sv.c +++ b/src/sv.c @@ -127,17 +127,16 @@ unsigned int svstatus_print(char *m) { pid <<=8; pid +=(unsigned char)svstatus[13]; pid <<=8; pid +=(unsigned char)svstatus[12]; tai_unpack(svstatus, &tstatus); - if (pid) { switch (svstatus[19]) { + case 0: outs(DOWN); break; case 1: outs(RUN); break; case 2: outs(FINISH); break; } - outs(m); outs(": (pid "); sulong[fmt_ulong(sulong, pid)] =0; - outs(sulong); outs(") "); - } - else { - outs(DOWN); outs(m); outs(": "); - } + outs(m); outs(": "); + if (svstatus[19]) { + outs("(pid "); sulong[fmt_ulong(sulong, pid)] =0; + outs(sulong); outs(") "); + } buffer_put(buffer_1, sulong, fmt_ulong(sulong, tnow.sec.x < tstatus.x ? 0 : tnow.sec.x -tstatus.x)); outs("s"); @@ -220,7 +219,7 @@ int check(char *a) { if (!pid || svstatus[19] != 1) return(0); if (!checkscript()) return(0); break; - case 'd': if (pid) return(0); break; + case 'd': if (pid || svstatus[19] != 0) return(0); break; case 'C': if (pid) if (!checkscript()) return(0); break; case 't': case 'k': |