Package: runlim / 1.10-5

runlim-rlimit_as.patch Patch series | download
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
From: Thomas Krennwallner <tkren@kr.tuwien.ac.at>
Date: Sun, 4 Dec 2016 14:25:30 +0100
Subject: Convert space limit to bytes for setrlimit(RLIMIT_AS)

===================================================================
---
 runlim.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/runlim.c b/runlim.c
index 2cf36fc..4c795d2 100644
--- a/runlim.c
+++ b/runlim.c
@@ -834,9 +834,16 @@ main (int argc, char **argv)
 	hard_time_limit = time_limit;
 	hard_time_limit = (hard_time_limit * 101 + 99) / 100;	// + 1%
 	l.rlim_cur = l.rlim_max = hard_time_limit;
-	setrlimit (RLIMIT_CPU, &l);
+	if (setrlimit (RLIMIT_CPU, &l)) {
+		perror ("setrlimit(RLIMIT_CPU)");
+		exit (1);
+	}
+	space_limit <<= 20; /* convert to bytes */
 	l.rlim_cur = l.rlim_max = space_limit;
-	setrlimit (RLIMIT_AS, &l);
+	if (setrlimit (RLIMIT_AS, &l)) {
+		perror ("setrlimit(RLIMIT_AS)");
+		exit (1);
+	}
       }
       execvp (argv[i], argv + i);
       kill (getppid (), SIGUSR1);