set CPU limit, in case the alarm handler will be ignored, MKWS-157
authorWolfram Schneider <wosch@indexdata.dk>
Fri, 27 Jun 2014 09:36:17 +0000 (11:36 +0200)
committerWolfram Schneider <wosch@indexdata.dk>
Fri, 27 Jun 2014 09:38:07 +0000 (11:38 +0200)
test/bin/bomb.pl

index 6211eab..4ce8590 100755 (executable)
@@ -6,6 +6,7 @@
 
 use Getopt::Long;
 use POSIX ":sys_wait_h";
+use BSD::Resource qw/setrlimit/;
 
 use strict;
 use warnings;
@@ -38,6 +39,10 @@ my @system = @ARGV;
 die usage if $help;
 die usage if !@system;
 
+# set CPU limit, in case the alarm handler will
+# be ignored
+setrlimit(RLIMIT_CPU, $timeout, 2*$timeout) or die "Cannot set CPU limit: $!\n";
+
 #
 # use fork/exec instead system()
 #
@@ -54,4 +59,3 @@ if ($pid) {
 else { }
 
 1;
-