lkml.org 
[lkml]   [2009]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [Bug #12911] Limiting cpu time doesn't work
Date
Hello,

additional info on subject.
problem first apeared in 2.6.27-git9 and RLIMIT_CPU actually works on process that sets limit but not on its children. examples:

test1.c
#include <sys/time.h>
#include <sys/resource.h>

int main() {
struct rlimit a;
a.rlim_cur=3;
a.rlim_max=5;
setrlimit(RLIMIT_CPU, &a);
while(1);
return 0;
}

test1 dies with "CPU time limit exceeded" after 3sec as expected, but

test2.c
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main() {
struct rlimit a;
int status;

a.rlim_cur=3;
a.rlim_max=5;
setrlimit(RLIMIT_CPU, &a);
if (0==fork())
while(1);
else
wait(&status);
return 0;
}

test2 not get killed. checking limits on child process show that limits set correctly.

two equivalent examples for shell:
sh -c "ulimit -t 3; while true; do true; done"
sh -c "ulimit -t 3; sh -c 'while true; do true; done'"



\
 
 \ /
  Last update: 2009-03-22 06:39    [W:0.034 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site