#!/usr/bin/perl use warnings; use strict; my $script = 'ps auxww'; eval { # from http://www.rocketaware.com/perl/perlfunc/alarm.htm local $SIG{ALRM} = sub { die "alarm\n" }; # NB \n required alarm(5); # set time limit to 5 sec system($script); alarm(0); # if $script finishes in <5sec reset alarm }; die if $@ && $@ ne "alarm\n"; # propagate errors if ($@) { print "Timeout! [$@]\n"; # do stuff if eval fails (eg timeout) }
In reply to Re: Using IPC::Run to kill stuck process
by zentara
in thread Using IPC::Run to kill stuck process
by filmotheklown
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |