• Michael Kerrisk's avatar
    [PATCH] Off-by-one error for SIGXCPU / RLIMIT_CPU checking · 81fd00e2
    Michael Kerrisk authored
    There is a lonstanding off-by-one error that results from an incorrect
    comparison when checking whether a process has consumed CPU time in
    excess of its RLIMIT_CPU limits. 
    
    This means, for example, that if we use setrlimit() to set the soft CPU 
    limit (rlim_cur) to 5 seconds and the hard limit (rlim_max) to 10 seconds, 
    then the process only receives a SIGXCPU signal after consuming 6 seconds
    of CPU time, and, if it continues consuming CPU after handling that
    signal, only receives SIGKILL after consuming 11 seconds of CPU time.
    
    The fix is trivial.
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    81fd00e2
timer.c 38.4 KB