On Tue, 4 Dec 2001, Doug MacEachern wrote:
> On Wed, 5 Dec 2001, Stas Bekman wrote:
>
> > ok, but that catches only syntax errors. if we can catch the return
> > status from system() we can catch all errors, causing the failure.
>
> that would be great.
ok, here it is. Have no clue whether you can re-use this for win32.
hmm, probably I should use POSIX::SIGINT() instead of 15 in kill.
Index: Apache-Test/lib/Apache/TestServer.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.46
diff -u -r1.46 TestServer.pm
--- Apache-Test/lib/Apache/TestServer.pm 2001/12/20 17:30:54 1.46
+++ Apache-Test/lib/Apache/TestServer.pm 2001/12/23 19:05:48
@@ -402,6 +402,8 @@
}
print "$cmd\n";
+ my $child_pid;
+ my $child_in_pipe;
if (Apache::TestConfig::WIN32) {
#make sure only 1 process is started for win32
@@ -418,7 +420,17 @@
$config->{win32obj} = $obj;
}
else {
- system "$cmd &";
+ require POSIX;
+ $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 15, $$;
+ }
+ }
+ };
+ $child_pid = open $child_in_pipe, "|$cmd";
}
while ($old_pid and $old_pid == $self->pid) {
@@ -450,6 +462,10 @@
last;
}
}
+
+ # now that the server has started don't abort the test run if it
+ # dies
+ $SIG{CHLD} = 'IGNORE';
if (my $pid = $self->pid) {
print "server $self->{name} started\n";
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/