#! perl -slw use strict; use Config; use Win32::Event; use Win32::Process; $|++; #print $Config{sig_name}; my $event = Win32::Event->new(1, 0, 'test'); if (not defined(my $pid = fork())) { warn "can not fork: $!\n"; return; } elsif ($pid) { print "Parent processid: $$; child:$pid"; if($event->wait( 5000 )) { print 'The child signalled and terminated'; } else { print 'Parent: child continuing after 5 secs'; if($event->wait( 5000 )) { print 'The child signalled and terminated'; } else { print 'Parent: child still continuing after 10 secs'; my $exitCode = 0; print "Parent: Attempting to kill processid $pid"; # Win32::Process::KillProcess( $pid, $exitCode ) or warn $^E; # print "Parent: KillProcess returned: $exitCode"; kill 9, $pid or die $!; print "Parent: KillProcess returned: $?"; } } print "Parent dying"; } else { for (1..20) { print "Child process: $$"; sleep 1; } print "Child: signalling parent"; $event->set; print "Child dying"; exit 12345; } __END__ #### C:\test>217881 Parent processid: 273; child:-295 Child process: -295 Child process: -295 Child process: -295 Child process: -295 Child process: -295 Parent: child continuing after 5 secs Child process: -295 Child process: -295 Child process: -295 Child process: -295 Child process: -295 Parent: child still continuing after 10 secs Parent: Attempting to kill processid -295 Parent: KillProcess returned: 0 Parent dying C:\test>