From 6ea9716f1fc13a976aad8af0ed3138c9bc6333d5 Mon Sep 17 00:00:00 2001 From: Gerrit Pape Date: Thu, 13 Sep 2007 13:16:21 +0000 Subject: sv.c: fix race on check for down if pid is 0 and state is run or finish. --- src/sv.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') 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': -- cgit 1.4.1