commit 71cf02e4a8b15b0df229fe9aa04fc82e1dfcb74b
parent d4764ec828dde4da6920a7064ce7b8d58faaa3d3
Author: Gerrit Pape <pape@smarden.org>
Date: Thu, 13 Sep 2007 13:16:21 +0000
sv.c: fix race on check for down if pid is 0 and state is run or finish.
Diffstat:
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git 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
@@ -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':