The http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/limit-cpu.c program in Fig. 8.4 illustrates setting the limit on CPU time consumed by a program. It sets a 1-second CPU time limit and then spins in an infinite loop. Linux kills the process soon afterward, when it exceeds 1 second of CPU time.
Figure 8.4:
CPU Time Limit Demonstration.
|
$ ./limit_cpu
CPU time limit exceeded