2
# Copyright (C) 2004-2006 MySQL AB
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
# This is a library file used by the Perl version of drizzle-test-run,
18
# and is part of the translation of the Bourne shell script with the
25
use POSIX qw(WNOHANG SIGHUP);
27
sub dtr_run ($$$$$$;$);
28
sub dtr_spawn ($$$$$$;$);
29
sub dtr_check_stop_servers ($);
30
sub dtr_kill_leftovers ();
31
sub dtr_wait_blocking ($);
32
sub dtr_record_dead_children ();
33
sub dtr_ndbmgm_start($$);
35
sub sleep_until_file_created ($$$);
36
sub dtr_kill_processes ($);
37
sub dtr_ping_with_timeout($);
38
sub dtr_ping_port ($);
41
sub spawn_impl ($$$$$$$);
43
##############################################################################
45
# Execute an external command
47
##############################################################################
49
sub dtr_run ($$$$$$;$) {
51
my $arg_list_t= shift;
55
my $pid_file= shift; # Not used
56
my $spawn_opts= shift;
58
return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,
62
sub dtr_run_test ($$$$$$;$) {
64
my $arg_list_t= shift;
68
my $pid_file= shift; # Not used
69
my $spawn_opts= shift;
71
return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,
75
sub dtr_spawn ($$$$$$;$) {
77
my $arg_list_t= shift;
81
my $pid_file= shift; # Not used
82
my $spawn_opts= shift;
84
return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,
90
sub spawn_impl ($$$$$$$) {
92
my $arg_list_t= shift;
97
my $spawn_opts= shift;
99
if ( $::opt_script_debug )
103
dtr_debug("STDIN $input") if $input;
104
dtr_debug("STDOUT $output") if $output;
105
dtr_debug("STDERR $error") if $error;
106
dtr_debug("$mode: $path ", join(" ",@$arg_list_t));
107
dtr_debug("spawn options:");
110
foreach my $key (sort keys %{$spawn_opts})
112
dtr_debug(" - $key: $spawn_opts->{$key}");
123
dtr_error("Can't spawn with empty \"path\"") unless defined $path;
130
if ( ! defined $pid )
132
if ( $! == $!{EAGAIN} ) # See "perldoc Errno"
134
dtr_warning("Got EAGAIN from fork(), sleep 1 second and redo");
139
dtr_error("$path ($pid) can't be forked, error: $!");
145
select(STDOUT) if $::glob_win32_perl;
146
return spawn_parent_impl($pid,$mode,$path);
150
# Child, redirect output and exec
152
$SIG{INT}= 'DEFAULT'; # Parent do some stuff, we don't
154
my $log_file_open_mode = '>';
156
if ($spawn_opts and $spawn_opts->{'append_log_file'})
158
$log_file_open_mode = '>>';
163
if ( $::glob_win32_perl )
165
# Don't redirect stdout on ActiveState perl since this is
166
# just another thread in the same process.
168
elsif ( ! open(STDOUT,$log_file_open_mode,$output) )
170
dtr_child_error("can't redirect STDOUT to \"$output\": $!");
176
if ( !$::glob_win32_perl and $output eq $error )
178
if ( ! open(STDERR,">&STDOUT") )
180
dtr_child_error("can't dup STDOUT: $!");
185
if ( ! open(STDERR,$log_file_open_mode,$error) )
187
dtr_child_error("can't redirect STDERR to \"$error\": $!");
194
if ( ! open(STDIN,"<",$input) )
196
dtr_child_error("can't redirect STDIN to \"$input\": $!");
200
if ( ! exec($path,@$arg_list_t) )
202
dtr_child_error("failed to execute \"$path\": $!");
204
dtr_error("Should never come here 1!");
206
dtr_error("Should never come here 2!");
208
dtr_error("Should never come here 3!");
212
sub spawn_parent_impl {
217
if ( $mode eq 'run' or $mode eq 'test' )
219
if ( $mode eq 'run' )
221
# Simple run of command, wait blocking for it to return
222
my $ret_pid= waitpid($pid,0);
223
if ( $ret_pid != $pid )
225
# The "simple" waitpid has failed, print debug info
226
# and try to handle the error
227
dtr_warning("waitpid($pid, 0) returned $ret_pid " .
228
"when waiting for '$path', error: '$!'");
229
if ( $ret_pid == -1 )
231
# waitpid returned -1, that would indicate the process
232
# no longer exist and waitpid couldn't wait for it.
235
dtr_error("Error handling failed");
238
return dtr_process_exit_status($?);
242
# We run drizzletest and wait for it to return. But we try to
243
# catch dying drizzled processes as well.
245
# We do blocking waitpid() until we get the return from the
246
# "drizzletest" call. But if a drizzled process dies that we
247
# started, we take this as an error, and kill drizzletest.
251
my $saved_exit_value;
252
my $ret_pid; # What waitpid() returns
254
while ( ($ret_pid= waitpid(-1,0)) != -1 )
256
# Someone terminated, don't know who. Collect
257
# status info first before $? is lost,
258
# but not $exit_value, this is flagged from
260
my $timer_name= dtr_timer_timeout($::glob_timers, $ret_pid);
263
if ( $timer_name eq "suite" )
266
# FIXME we should only give up the suite, not all of the run?
268
dtr_error("Test suite timeout");
270
elsif ( $timer_name eq "testcase" )
272
$saved_exit_value= 63; # Mark as timeout
273
kill(9, $pid); # Kill drizzletest
274
next; # Go on and catch the termination
278
if ( $ret_pid == $pid )
280
# We got termination of drizzletest, we are done
281
$exit_value= dtr_process_exit_status($?);
285
# One of the child processes died, unless this was expected
286
# drizzletest should be killed and test aborted
288
check_expected_crash_and_restart($ret_pid);
291
if ( $ret_pid != $pid )
293
# We terminated the waiting because a "drizzled" process died.
294
# Kill the drizzletest process.
295
dtr_verbose("Kill drizzletest because another process died");
298
$ret_pid= waitpid($pid,0);
300
if ( $ret_pid != $pid )
302
dtr_error("$path ($pid) got lost somehow");
306
return $saved_exit_value || $exit_value;
311
# We spawned a process we don't wait for
317
# ----------------------------------------------------------------------
318
# We try to emulate how an Unix shell calculates the exit code
319
# ----------------------------------------------------------------------
321
sub dtr_process_exit_status {
322
my $raw_status= shift;
324
if ( $raw_status & 127 )
326
return ($raw_status & 127) + 128; # Signal num + 128
330
return $raw_status >> 8; # Exit code
335
##############################################################################
337
# Kill processes left from previous runs
339
##############################################################################
342
# Kill all processes(drizzled, ndbd, ndb_mgmd and im) that would conflict with
344
# Make sure to remove the PID file, if any.
345
# kill IM manager first, else it will restart the servers
346
sub dtr_kill_leftovers () {
348
dtr_report("Killing Possible Leftover Processes");
349
dtr_debug("dtr_kill_leftovers(): started.");
354
foreach my $srv (@{$::master}, @{$::slave})
356
dtr_debug(" - drizzled " .
357
"(pid: $srv->{pid}; " .
358
"pid file: '$srv->{path_pid}'; " .
359
"socket: '$srv->{path_sock}'; ".
360
"port: $srv->{port})");
362
my $pid= dtr_server_shutdown($srv);
364
# Save the pid of the drizzle client process
365
$admin_pids{$pid}= 1;
368
pid => $srv->{'pid'},
369
pidfile => $srv->{'path_pid'},
370
sockfile => $srv->{'path_sock'},
371
port => $srv->{'port'},
373
$srv->{'pid'}= 0; # Assume we are done with it
376
# Wait for all the admin processes to complete
377
dtr_wait_blocking(\%admin_pids);
379
# If we trusted "drizzleadmin --shutdown_timeout= ..." we could just
380
# terminate now, but we don't (FIXME should be debugged).
381
# So we try again to ping and at least wait the same amount of time
382
# drizzleadmin would for all to die.
384
dtr_ping_with_timeout(\@kill_pids);
386
# We now have tried to terminate nice. We have waited for the listen
387
# port to be free, but can't really tell if the drizzled process died
388
# or not. We now try to find the process PID from the PID file, and
389
# send a kill to that process. Note that Perl let kill(0,@pids) be
390
# a way to just return the numer of processes the kernel can send
391
# signals to. So this can be used (except on Cygwin) to determine
392
# if there are processes left running that we cound out might exists.
394
# But still after all this work, all we know is that we have
397
# We scan the "var/run/" directory for other process id's to kill
399
my $rundir= "$::opt_vardir/run";
401
dtr_debug("Processing PID files in directory '$rundir'...");
405
opendir(RUNDIR, $rundir)
406
or dtr_error("can't open directory \"$rundir\": $!");
410
while ( my $elem= readdir(RUNDIR) )
412
# Only read pid from files that end with .pid
413
if ( $elem =~ /.*[.]pid$/)
415
my $pidfile= "$rundir/$elem";
419
dtr_debug("Processing PID file: '$pidfile'...");
421
my $pid= dtr_get_pid_from_file($pidfile);
423
dtr_debug("Got pid: $pid from file '$pidfile'");
425
if ( $::glob_cygwin_perl or kill(0, $pid) )
427
dtr_debug("There is process with pid $pid -- scheduling for kill.");
428
push(@pids, $pid); # We know (cygwin guess) it exists
432
dtr_debug("There is no process with pid $pid -- skipping.");
438
dtr_warning("Found non pid file $elem in $rundir")
439
if -f "$rundir/$elem";
447
dtr_debug("Killing the following processes with PID files: " .
448
join(' ', @pids) . "...");
452
if ( $::glob_cygwin_perl )
454
# We have no (easy) way of knowing the Cygwin controlling
455
# process, in the PID file we only have the Windows process id.
456
system("kill -f " . join(" ",@pids)); # Hope for the best....
457
dtr_debug("Sleep 5 seconds waiting for processes to die");
462
my $retries= 10; # 10 seconds
465
dtr_debug("Sending SIGKILL to pids: " . join(' ', @pids));
467
dtr_report("Sleep 1 second waiting for processes to die");
468
sleep(1) # Wait one second
469
} while ( $retries-- and kill(0, @pids) );
471
if ( kill(0, @pids) ) # Check if some left
473
dtr_warning("can't kill process(es) " . join(" ", @pids));
482
dtr_debug("Directory for PID files ($rundir) does not exist.");
485
# We may have failed everything, but we now check again if we have
486
# the listen ports free to use, and if they are free, just go for it.
488
dtr_debug("Checking known drizzled servers...");
490
foreach my $srv ( @kill_pids )
492
if ( defined $srv->{'port'} and dtr_ping_port($srv->{'port'}) )
494
dtr_warning("can't kill old process holding port $srv->{'port'}");
498
dtr_debug("dtr_kill_leftovers(): finished.");
503
# Check that all processes in "spec" are shutdown gracefully
504
# else kill them off hard
506
sub dtr_check_stop_servers ($) {
509
# Return if no processes are defined
512
dtr_verbose("dtr_check_stop_servers");
514
# ----------------------------------------------------------------------
515
# Wait until servers in "spec" has stopped listening
516
# to their ports or timeout occurs
517
# ----------------------------------------------------------------------
518
dtr_ping_with_timeout(\@$spec);
520
# ----------------------------------------------------------------------
521
# Use waitpid() nonblocking for a little while, to see how
522
# many process's will exit sucessfully.
523
# This is the normal case.
524
# ----------------------------------------------------------------------
525
my $wait_counter= 10; # Max number of times to redo the loop
526
foreach my $srv ( @$spec )
528
my $pid= $srv->{'pid'};
532
$ret_pid= waitpid($pid,&WNOHANG);
533
if ($ret_pid == $pid)
535
dtr_verbose("Caught exit of process $ret_pid");
538
elsif ($ret_pid == 0)
540
dtr_verbose("Process $pid is still alive");
541
if ($wait_counter-- > 0)
543
# Give the processes more time to exit
544
select(undef, undef, undef, (1));
550
dtr_warning("caught exit of unknown child $ret_pid");
555
# ----------------------------------------------------------------------
556
# The processes that haven't yet exited need to
557
# be killed hard, put them in "kill_pids" hash
558
# ----------------------------------------------------------------------
560
foreach my $srv ( @$spec )
562
my $pid= $srv->{'pid'};
565
# Server is still alive, put it in list to be hard killed
566
if ($::glob_win32_perl)
568
# Kill the real process if it's known
569
$pid= $srv->{'real_pid'} if ($srv->{'real_pid'});
573
# Write a message to the process's error log (if it has one)
574
# that it's being killed hard.
575
if ( defined $srv->{'errfile'} )
577
dtr_tofile($srv->{'errfile'}, "Note: Forcing kill of process $pid\n");
579
dtr_warning("Forcing kill of process $pid");
584
# Server is dead, remove the pidfile if it exists
586
# Race, could have been removed between test with -f
587
# and the unlink() below, so better check again with -f
588
if ( -f $srv->{'pidfile'} and ! unlink($srv->{'pidfile'}) and
589
-f $srv->{'pidfile'} )
591
dtr_error("can't remove $srv->{'pidfile'}");
596
if ( ! keys %kill_pids )
598
# All processes has exited gracefully
602
dtr_kill_processes(\%kill_pids);
604
# ----------------------------------------------------------------------
605
# All processes are killed, cleanup leftover files
606
# ----------------------------------------------------------------------
609
foreach my $srv ( @$spec )
613
# Server has been hard killed, clean it's resources
614
foreach my $file ($srv->{'pidfile'}, $srv->{'sockfile'})
616
# Know it is dead so should be no race, careful anyway
617
if ( defined $file and -f $file and ! unlink($file) and -f $file )
620
dtr_warning("couldn't delete $file");
624
if ($::glob_win32_perl and $srv->{'real_pid'})
626
# Wait for the pseudo pid - if the real_pid was known
627
# the pseudo pid has not been waited for yet, wai blocking
628
# since it's "such a simple program"
629
dtr_verbose("Wait for pseudo process $srv->{'pid'}");
630
my $ret_pid= waitpid($srv->{'pid'}, 0);
631
dtr_verbose("Pseudo process $ret_pid died");
639
# There where errors killing processes
640
# do one last attempt to ping the servers
641
# and if they can't be pinged, assume they are dead
642
if ( ! dtr_ping_with_timeout( \@$spec ) )
644
dtr_error("we could not kill or clean up all processes");
648
dtr_verbose("All ports were free, continuing");
655
# Wait for all the process in the list to terminate
656
sub dtr_wait_blocking($) {
657
my $admin_pids= shift;
660
# Return if no processes defined
661
return if ! %$admin_pids;
663
dtr_verbose("dtr_wait_blocking");
665
# Wait for all the started processes to exit
666
# As drizzleadmin is such a simple program, we trust it to terminate itself.
667
# I.e. we wait blocking, and wait for them all before we go on.
668
foreach my $pid (keys %{$admin_pids})
670
my $ret_pid= waitpid($pid,0);
675
sub dtr_server_shutdown($) {
679
dtr_init_args(\$args);
680
dtr_add_arg($args, "--shutdown");
681
dtr_add_arg($args, "--user=%s", $::opt_user);
682
dtr_add_arg($args, "--password=");
683
dtr_add_arg($args, "--silent");
685
if ( -e $srv->{'path_sock'} )
687
dtr_add_arg($args, "--socket=%s", $srv->{'path_sock'});
690
if ( $srv->{'port'} )
692
dtr_add_arg($args, "--port=%s", $srv->{'port'});
695
dtr_add_arg($args, "--connect_timeout=5");
697
my $pid= dtr_spawn($::exe_drizzle, $args,
698
"", "", "", "", { append_log_file => 1 });
699
dtr_verbose("dtr_server_shutdown, pid: $pid");
703
# Start "ndb_mgm shutdown" for a specific cluster, it will
704
# shutdown all data nodes and leave the ndb_mgmd running
705
sub dtr_ndbmgm_start($$) {
711
dtr_init_args(\$args);
713
dtr_add_arg($args, "--no-defaults");
714
dtr_add_arg($args, "--core");
715
dtr_add_arg($args, "--try-reconnect=1");
716
dtr_add_arg($args, "--ndb_connectstring=%s", $cluster->{'connect_string'});
717
dtr_add_arg($args, "-e");
718
dtr_add_arg($args, "$command");
720
my $pid= dtr_spawn($::exe_ndb_mgm, $args,
721
"", "/dev/null", "/dev/null", "",
723
dtr_verbose("dtr_ndbmgm_start, pid: $pid");
729
# Ping all servers in list, exit when none of them answers
730
# or when timeout has passed
731
sub dtr_ping_with_timeout($) {
733
my $timeout= 200; # 20 seconds max
734
my $res= 1; # If we just fall through, we are done
735
# in the sense that the servers don't
736
# listen to their ports any longer
738
dtr_debug("Waiting for drizzled servers to stop...");
743
foreach my $srv ( @$spec )
745
$res= 1; # We are optimistic
746
if ( $srv->{'pid'} and defined $srv->{'port'} )
748
if ( dtr_ping_port($srv->{'port'}) )
750
dtr_verbose("waiting for process $srv->{'pid'} to stop ".
751
"using port $srv->{'port'}");
753
# Millisceond sleep emulated with select
754
select(undef, undef, undef, (0.1));
760
# Process was not using port
764
last; # If we got here, we are done
769
dtr_debug("dtr_ping_with_timeout(): All drizzled instances are down.");
773
dtr_report("dtr_ping_with_timeout(): At least one server is alive.");
781
# Loop through our list of processes and look for and entry
782
# with the provided pid
783
# Set the pid of that process to 0 if found
785
sub mark_process_dead($)
789
foreach my $drizzled (@{$::master}, @{$::slave})
791
if ( $drizzled->{'pid'} eq $ret_pid )
793
dtr_verbose("$drizzled->{'type'} $drizzled->{'idx'} exited, pid: $ret_pid");
794
$drizzled->{'pid'}= 0;
799
foreach my $cluster (@{$::clusters})
801
if ( $cluster->{'pid'} eq $ret_pid )
803
dtr_verbose("$cluster->{'name'} cluster ndb_mgmd exited, pid: $ret_pid");
804
$cluster->{'pid'}= 0;
808
foreach my $ndbd (@{$cluster->{'ndbds'}})
810
if ( $ndbd->{'pid'} eq $ret_pid )
812
dtr_verbose("$cluster->{'name'} cluster ndbd exited, pid: $ret_pid");
818
dtr_warning("mark_process_dead couldn't find an entry for pid: $ret_pid");
823
# Loop through our list of processes and look for and entry
824
# with the provided pid, if found check for the file indicating
825
# expected crash and restart it.
827
sub check_expected_crash_and_restart($)
831
foreach my $drizzled (@{$::master}, @{$::slave})
833
if ( $drizzled->{'pid'} eq $ret_pid )
835
dtr_verbose("$drizzled->{'type'} $drizzled->{'idx'} exited, pid: $ret_pid");
836
$drizzled->{'pid'}= 0;
838
# Check if crash expected and restart if it was
839
my $expect_file= "$::opt_vardir/tmp/" . "$drizzled->{'type'}" .
840
"$drizzled->{'idx'}" . ".expect";
841
if ( -f $expect_file )
843
dtr_verbose("Crash was expected, file $expect_file exists");
844
drizzled_start($drizzled, $drizzled->{'start_opts'},
845
$drizzled->{'start_slave_master_info'});
846
unlink($expect_file);
853
foreach my $cluster (@{$::clusters})
855
if ( $cluster->{'pid'} eq $ret_pid )
857
dtr_verbose("$cluster->{'name'} cluster ndb_mgmd exited, pid: $ret_pid");
858
$cluster->{'pid'}= 0;
860
# Check if crash expected and restart if it was
861
my $expect_file= "$::opt_vardir/tmp/ndb_mgmd_" . "$cluster->{'type'}" .
863
if ( -f $expect_file )
865
dtr_verbose("Crash was expected, file $expect_file exists");
866
ndbmgmd_start($cluster);
867
unlink($expect_file);
872
foreach my $ndbd (@{$cluster->{'ndbds'}})
874
if ( $ndbd->{'pid'} eq $ret_pid )
876
dtr_verbose("$cluster->{'name'} cluster ndbd exited, pid: $ret_pid");
879
# Check if crash expected and restart if it was
880
my $expect_file= "$::opt_vardir/tmp/ndbd_" . "$cluster->{'type'}" .
881
"$ndbd->{'idx'}" . ".expect";
882
if ( -f $expect_file )
884
dtr_verbose("Crash was expected, file $expect_file exists");
885
ndbd_start($cluster, $ndbd->{'idx'},
886
$ndbd->{'start_extra_args'});
887
unlink($expect_file);
894
if ($::instance_manager->{'spawner_pid'} eq $ret_pid)
899
dtr_warning("check_expected_crash_and_restart couldn't find an entry for pid: $ret_pid");
903
##############################################################################
905
# The operating system will keep information about dead children,
906
# we read this information here, and if we have records the process
907
# is alive, we mark it as dead.
909
##############################################################################
911
sub dtr_record_dead_children () {
916
# Wait without blockinng to see if any processes had died
917
# -1 or 0 means there are no more procesess to wait for
918
while ( ($ret_pid= waitpid(-1,&WNOHANG)) != 0 and $ret_pid != -1)
920
dtr_warning("dtr_record_dead_children: $ret_pid");
921
mark_process_dead($ret_pid);
924
return $process_died;
928
# This causes terminating processes to not become zombies, avoiding
929
# the need for (or possibility of) explicit waitpid().
930
$SIG{CHLD}= 'IGNORE';
932
# On some platforms (Linux, QNX, OSX, ...) there is potential race
933
# here. If a process terminated before setting $SIG{CHLD} (but after
934
# any attempt to waitpid() it), it will still be a zombie. So we
935
# have to handle any such process here.
937
while(($pid= waitpid(-1, &WNOHANG)) != 0 and $pid != -1)
939
dtr_warning("start_reap_all pid: $pid");
940
mark_process_dead($pid);
945
$SIG{CHLD}= 'DEFAULT';
949
sub dtr_ping_port ($) {
952
dtr_verbose("dtr_ping_port: $port");
954
my $remote= "localhost";
955
my $iaddr= inet_aton($remote);
958
dtr_error("can't find IP number for $remote");
960
my $paddr= sockaddr_in($port, $iaddr);
961
my $proto= getprotobyname('tcp');
962
if ( ! socket(SOCK, PF_INET, SOCK_STREAM, $proto) )
964
dtr_error("can't create socket: $!");
967
dtr_debug("Pinging server (port: $port)...");
969
if ( connect(SOCK, $paddr) )
971
close(SOCK); # FIXME check error?
982
##############################################################################
984
# Wait for a file to be created
986
##############################################################################
988
# FIXME check that the pidfile contains the expected pid!
990
sub sleep_until_file_created ($$$) {
994
my $sleeptime= 100; # Milliseconds
995
my $loops= ($timeout * 1000) / $sleeptime;
997
for ( my $loop= 1; $loop <= $loops; $loop++ )
1004
# Check if it died after the fork() was successful
1005
if ( $pid != 0 && waitpid($pid,&WNOHANG) == $pid )
1007
dtr_warning("Process $pid died");
1011
dtr_debug("Sleep $sleeptime milliseconds waiting for $pidfile");
1013
# Print extra message every 60 seconds
1014
my $seconds= ($loop * $sleeptime) / 1000;
1015
if ( $seconds > 1 and int($seconds * 10) % 600 == 0 )
1017
my $left= $timeout - $seconds;
1018
dtr_warning("Waited $seconds seconds for $pidfile to be created, " .
1019
"still waiting for $left seconds...");
1022
# Millisceond sleep emulated with select
1023
select(undef, undef, undef, ($sleeptime/1000));
1030
sub dtr_kill_processes ($) {
1033
dtr_verbose("dtr_kill_processes (" . join(" ", keys %{$pids}) . ")");
1035
foreach my $pid (keys %{$pids})
1040
dtr_warning("Trying to kill illegal pid: $pid");
1044
my $signaled_procs= kill(9, $pid);
1045
if ($signaled_procs == 0)
1047
# No such process existed, assume it's killed
1048
dtr_verbose("killed $pid(no such process)");
1052
my $ret_pid= waitpid($pid,0);
1053
if ($ret_pid == $pid)
1055
dtr_verbose("killed $pid(got the pid)");
1057
elsif ($ret_pid == -1)
1059
dtr_verbose("killed $pid(got -1)");
1063
dtr_verbose("done killing processes");
1067
##############################################################################
1069
# When we exit, we kill off all children
1071
##############################################################################
1075
dtr_timer_stop_all($::glob_timers);
1076
local $SIG{HUP} = 'IGNORE';
1077
# ToDo: Signalling -$$ will only work if we are the process group
1078
# leader (in fact on QNX it will signal our session group leader,
1079
# which might be Do-compile or Pushbuild, causing tests to be
1080
# aborted). So we only do it if we are the group leader. We might
1081
# set ourselves as the group leader at startup (with
1082
# POSIX::setpgrp(0,0)), but then care must be needed to always do
1083
# proper child process cleanup.
1084
POSIX::kill(SIGHUP, -$$) if !$::glob_win32_perl and $$ == getpgrp();
1089
###########################################################################