Messages in this thread | | | From | Peter Lojkin <> | Subject | Re: [Bug #12911] Limiting cpu time doesn't work | Date | Sun, 22 Mar 2009 08:34:49 +0300 |
| |
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'"
| |