From 157cc4927ff8aa7af63bc59f8eade6cb3f14c6d6 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Wed, 24 Jul 2013 02:47:29 +0000 Subject: [PATCH 1/1] use t_setrlim in the run command --- src/common/run.c | 16 ++-------------- src/common/setrlim.c | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/common/run.c b/src/common/run.c index 8a2a0f3..36f3c5e 100644 --- a/src/common/run.c +++ b/src/common/run.c @@ -14,26 +14,14 @@ static void handler(int s) { } -static void setrl(int r, long lim) { - struct rlimit rl; - - if (getrlimit(r, &rl)) - t_error("getrlimit %d: %s\n", r, strerror(errno)); - rl.rlim_cur = lim; - if (lim < rl.rlim_max) - rl.rlim_max = lim; - if (setrlimit(r, &rl)) - t_error("setrlimit %d: %s\n", r, strerror(errno)); -} - static int start(char *argv[]) { int pid; pid = fork(); if (pid == 0) { - setrl(RLIMIT_STACK, 100*1024); - setrl(RLIMIT_CPU, 2); + t_setrlim(RLIMIT_STACK, 100*1024); + t_setrlim(RLIMIT_CPU, 2); execv(argv[0], argv); t_error("%s exec failed: %s\n", argv[0], strerror(errno)); exit(1); diff --git a/src/common/setrlim.c b/src/common/setrlim.c index fc76a8e..cc89f61 100644 --- a/src/common/setrlim.c +++ b/src/common/setrlim.c @@ -18,7 +18,7 @@ int t_setrlim(int r, long lim) rl.rlim_max = lim; rl.rlim_cur = lim; if (setrlimit(r, &rl)) { - t_error("setrlimit %d: %s\n", r, strerror(errno)); + t_error("setrlimit(%d, %ld): %s\n", r, lim, strerror(errno)); return -1; } return 0; -- 2.20.1