in reply to Re: how to stop command
in thread how to stop command
my $timeout = 5; eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; my @file_list = `ls user/test/`; my $file; my @file_list; foreach $file(@file_list){ print "$file\n"; } alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors # timed out } else { # didn't }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to stop command
by hippo (Archbishop) on Jul 22, 2018 at 10:52 UTC |