Reputation: 32986
I want to set limits for how long programs spawned by execv can use a certain amount of memory and a certain amount of CPU time. For example, I want to set limits like a program cannot exceed 100MB for 30 seconds, and a program cannot use 90% or more of the CPU for more than 20 seconds.
Upvotes: 2
Views: 471
Reputation: 798526
No. You will need to run some sort of supervisor "around" the code, either as a program that will fork/exec, or as an injected library that will intercept libc/system calls.
Upvotes: 1
Reputation: 249123
You can use RLIMIT_CPU
, RLIMIT_DATA
and friends, but none of them has any concept of time duration or windowing. If those work for you as they are, great; if not, can you explain in more detail the problem you are trying to solve?
Upvotes: 2