Learn R Programming

RAppArmor (version 0.6.0)

rlimit_cpu: Limit CPU time

Description

CPU time limit in seconds. When the process reaches the soft limit, it is sent a SIGXCPU signal. Note that CPU time is not the same as elapsed time. If a process is waiting/idle, it will not hit the CPU time limit.

Usage

rlimit_cpu(hardlim, softlim = hardlim, pid = 0,
    verbose = TRUE)

Arguments

hardlim
cpu time in seconds
softlim
cpu time in seconds
pid
id of the target process
verbose
print some C output (TRUE/FALSE)

Details

CPU time limit in seconds. When the process reaches the soft limit, it is sent a SIGXCPU signal. The default action for this signal is to terminate the process. However, the signal can be caught, and the handler can return control to the main program. If the process continues to consume CPU time, it will be sent SIGXCPU once per second until the hard limit is reached, at which time it is sent SIGKILL. (This latter point describes Linux behavior. Implementations vary in how they treat rocesses which continue to consume CPU time after reaching the soft limit. Portable applications that need to catch this signal should perform an orderly termination upon first receipt of SIGXCPU.)

See Also

Other rlimit: rlimit_as, rlimit_core, rlimit_data, rlimit_fsize, rlimit_memlock, rlimit_msgqueue, rlimit_nice, rlimit_nofile, rlimit_nproc, rlimit_rtprio, rlimit_rttime, rlimit_sigpending, rlimit_stack

Examples

Run this code
#load lib
library(RAppArmor)

#current limit
rlimit_as();

#set hard limit
rlimit_as(1e9);

#set separate hard and soft limit. 
rlimit_as(1e9, 1e8);

#soft limits can be elevated
rlimit_as(soft = 1e7);
rlimit_as(soft = 1e9);

#set other limits
rlimit_core(1e9);
rlimit_data(1e9);
rlimit_fsize(1e9);
rlimit_memlock(10000);
rlimit_msgqueue(1e5);
rlimit_nofile(10);
rlimit_nproc(100);
rlimit_rttime(1e9);
rlimit_sigpending(1e4);
rlimit_stack(1000);
rlimit_cpu(10);

Run the code above in your browser using DataLab