in reply to Re^2: Backticks and SIGALRM
in thread Backticks and SIGALRM
e.g. run the code under a piped open, something like this (untested):
If your child process starts yet more children (and they don't exit when the parent is killed), you'll have to write more elaborate cleanup code.my $cmd = "your command"; my $pid = open(my $fh, "$cmd|"); $SIG{ALRM} = sub { print "Alarm fired, killing pid $pid\n"; # Replace with windows-specific code to kill process kill 15, $pid; }; die "Can't run command [$cmd] : $!" unless $pid; # Or do some other processing with $fh push @result, $_ while (<$fh>); close $fh or die "Problem running [$cmd] : $?";
Dig through the windows-related process modules on CPAN and you should find what you need for the cleanup.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Backticks and SIGALRM
by sgt (Deacon) on Aug 21, 2007 at 14:14 UTC |