Commit dffbfd10 authored by Andrei Paskevich's avatar Andrei Paskevich

prohibit core dumping when limits are enforced

parent ebc54ea1
......@@ -84,12 +84,19 @@ int main(int argc, char *argv[]) {
memlimit = atol(argv[2]);
if (memlimit > 0) {
/* set the CPU time limit */
/* set the CPU memory limit */
getrlimit(RLIMIT_AS,&res);
res.rlim_cur = memlimit * 1024 * 1024;
setrlimit(RLIMIT_AS,&res);
}
if (timelimit > 0 || memlimit > 0) {
/* do not generate core dumps */
getrlimit(RLIMIT_CORE,&res);
res.rlim_cur = 0;
setrlimit(RLIMIT_CORE,&res);
}
/* execute the command */
execvp(argv[4],argv+4);
fprintf(stderr, "%s: exec of '%s' failed (%s)\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment