aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-01-14 19:28:54 +0000
committerYang Tse <yangsita@gmail.com>2008-01-14 19:28:54 +0000
commit69f685056dc8396f9bc4772e74c5a846accb51e0 (patch)
tree8418d02e99e14aabfedf2a90b2b9831da1acb70c /tests
parent9c7d4394f9ec16d29f00286e7fdab4badb3cd410 (diff)
startnew() shouldn't return a positive pid as reported in the pidfile
by the spawned server itself unless it is actually alive
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runtests.pl7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 4bc32bf36..86687eeb1 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -297,7 +297,7 @@ sub startnew {
logmsg "startnew: $cmd\n" if ($verbose);
my $child = fork();
- my $pid2;
+ my $pid2 = 0;
if(not defined $child) {
logmsg "startnew: fork() failure detected\n";
@@ -336,8 +336,7 @@ sub startnew {
my $count = $timeout;
while($count--) {
- if(-f $pidfile) {
- open(PID, "<$pidfile");
+ if(-f $pidfile && -s $pidfile && open(PID, "<$pidfile")) {
$pid2 = 0 + <PID>;
close(PID);
if(($pid2 > 0) && kill(0, $pid2)) {
@@ -346,6 +345,8 @@ sub startnew {
# similar!
last;
}
+ # invalidate $pid2 if not actually alive
+ $pid2 = 0;
}
if (checkdied($child)) {
logmsg "startnew: child process has died, server might start up\n"