Re: how to get the output from: Win32::Process::Create
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 31 Aug 2006 13:12:09 -0700
Paul Lalli wrote:
You apparently have two requirements. One is that you need to capture
the output of the program. The other is that you need to get the pid
of the program so you can later kill it. These two requirements seem,
to me, to be contraditory.
I guess the other possibility is to fork your program, and set up the
child to have a signal handler to be notified when the parent wants to
kill it....
[untested]
my $pid = fork();
if ($pid == 0) { #child
$SIG{INT} = sub { print "Parent told me to die!\n"; exit };
open my $pipe, "test.exe |" or die "Cannot open pipe: $!";
while (my $line = <$pipe>) {
process_line($line);
}
print "test.exe ended before parent told me to die!\n";
}
else { #parent
#do stuff
# la la la
if (want_to_kill()) {
kill ('INT', $pid);
}
#do more stuff, la la la
}
Paul Lalli
.
- References:
- how to get the output from: Win32::Process::Create
- From: joez3
- Re: how to get the output from: Win32::Process::Create
- From: Paul Lalli
- Re: how to get the output from: Win32::Process::Create
- From: joez3
- Re: how to get the output from: Win32::Process::Create
- From: Paul Lalli
- how to get the output from: Win32::Process::Create
- Prev by Date: Re: how to get the output from: Win32::Process::Create
- Previous by thread: Re: how to get the output from: Win32::Process::Create
- Next by thread: Re: how to get the output from: Win32::Process::Create
- Index(es):
Relevant Pages
|
|