$pid=fork(); exec("notepad"); $SIG{INT}=\&handler; sub handler { kill 1,$pid; } #### my $pid = fork() ; die "fork failed '$!'" if !defined($pid) ; if ($pid == 0) { exec("notepad") ; } ; print "Started Notepad \$pid = $pid\n" ; my $r = 1 ; sub handler { kill 'INT', $pid ; $r = 0 ; } ; $SIG{INT}=\&handler; while ($r) { sleep(1) } ; print "And we're done\n" ; #### use strict ; use warnings ; use Win32::Process ; use Win32 ; my $SystemRoot = $ENV{SystemRoot} ; print "\$SystemRoot = '$SystemRoot'\n" ; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } my $ProcessObj ; Win32::Process::Create($ProcessObj, "$SystemRoot\\notepad.exe", "notepad", 0, NORMAL_PRIORITY_CLASS, "." ) or die ErrorReport() ; my $pid = $ProcessObj->GetProcessID() ; print "Started Notepad \$pid = $pid\n" ; my $run = 1 ; sub handler { $ProcessObj->Kill(1234) ; $run = 0 ; } ; $SIG{INT}=\&handler; while ($run) { sleep(1) } ; print "And we're done\n" ;