6 Einträge, 1 Seite |
nepos+2008-08-27 14:56:10--Du kannst mittels alarm() einen Timer benutzen.
[...]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
use strict; use warnings; use constant { TIMEOUT => 3 }; my $pid = fork; die "Failed to spawn subprocess: $!\n" unless (defined($pid)); if ($pid) { $SIG{ALRM} = sub { kill TERM => $pid; }; alarm TIMEOUT; if (waitpid($pid, 0) == $pid) { my ($err, $sig) = ($? >> 8, $? & 127); if ($sig) { print "Child died from signal $sig\n"; exit $sig; } else { print "Child exited normally with status $err\n"; exit $err; } } else { die "Error waiting for child: $!\n"; } } else { exec @ARGV or die "Failed to run command: $!\n"; }
system("ulimit -t 1; factor 9999999999999999987");
6 Einträge, 1 Seite |