----- Original Message ----- 
From: "m.nooning" <[EMAIL PROTECTED]>

Sorry - I missed your initial post.
.
.
.
> >
> > $ProcessObj->Wait(2000);
> > my $pid = $ProcessObj-> GetProcessID();
> > print "About to kill pid $pid\n";
> > $ProcessObj->Kill($pid);
> >

You don't need to get the PID. Simply:

$ProcessObj->Wait(2000);
print "About to kill process\n";
my $exitcode = 9; # or whatever you want
$ProcessObj->Kill($exitcode);

.
.
>
> I do not think this is a par/pp problem.

That's correct - but it's an interesting issue nonetheless. You can
demonstrate the same thing with perl only:

-----------------------------------------------
D:\pscrpt>type launcher.pl

use warnings;
use strict;
use Win32::Process;

my $ProcessObj = "";

Win32::Process::Create(
                       $ProcessObj,
                       "D:/perl58_M/5.8.8/bin/perl.exe", # ammend
appropriately
                       "perl parent.pl",
                       0,
                       Win32::Process->NORMAL_PRIORITY_CLASS,
                       ".")|| die ("Cannot Win32::Process::Create:$!:\n");

$ProcessObj->Wait(3000);
my $pid = $ProcessObj-> GetProcessID();
print "About to kill PID $pid\n";
my $exitcode = 9;
$ProcessObj->Kill(9);

D:\pscrpt>type parent.pl

use warnings;
print "parent PID = $$\n";
system("perl child.pl");

D:\pscrpt>type child.pl

use warnings;
while (1) {
  print "Child PID: $$\n";
  sleep(1);
}

D:\pscrpt>perl launcher.pl
parent PID = 1516
Child PID: 1612
Child PID: 1612
Child PID: 1612
About to kill PID 1516

D:\pscrpt>Child PID: 1612
Child PID: 1612
Child PID: 1612
Child PID: 1612
Terminating on signal SIGINT(2)  # when I hit Ctrl-C
-------------------------------------------------

There may be a way to have Win32::Process kill the current process && any
child processes as well. But I, for one, don't know how to do that.
You can, of course, have Win32::Process kill the child process by using the
Win32::Process::KillProcess($pid, $exitcode) function. But you have to be
able to provide that function with the appropriate PID value - and that can
be tricky.

Cheers,
Rob

Reply via email to