You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-cvs@httpd.apache.org by st...@apache.org on 2001/12/31 11:58:22 UTC
cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestServer.pm
stas 01/12/31 02:58:22
Modified: perl-framework/Apache-Test/lib/Apache TestServer.pm
Log:
- terminate t/TEST immediately if the spawned httpd has failed, use fork
(via pipe) to detect the SIGCHLD exit condition during startup stage.
Revision Changes Path
1.47 +20 -1 httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm
Index: TestServer.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- TestServer.pm 20 Dec 2001 17:30:54 -0000 1.46
+++ TestServer.pm 31 Dec 2001 10:58:22 -0000 1.47
@@ -402,6 +402,9 @@
}
print "$cmd\n";
+ my $child_pid;
+ my $child_in_pipe;
+ my $old_sig;
if (Apache::TestConfig::WIN32) {
#make sure only 1 process is started for win32
@@ -418,7 +421,19 @@
$config->{win32obj} = $obj;
}
else {
- system "$cmd &";
+ # XXX: try not to be POSIX dependent
+ require POSIX;
+ $old_sig = $SIG{CHLD};
+ $SIG{CHLD} = sub {
+ while ((my $child = waitpid(-1, POSIX::WNOHANG())) > 0) {
+ my $status = $? >> 8;
+ if ($status) {
+ $self->failed_msg("\nserver has died with status $status");
+ kill SIGTERM => $$;
+ }
+ }
+ };
+ $child_pid = open $child_in_pipe, "|$cmd";
}
while ($old_pid and $old_pid == $self->pid) {
@@ -450,6 +465,10 @@
last;
}
}
+
+ # now that the server has started don't abort the test run if it
+ # dies
+ $SIG{CHLD} = $old_sig || 'DEFAULT';
if (my $pid = $self->pid) {
print "server $self->{name} started\n";