Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Let's say I have program #1 launching program #2 which is launching program #3.

If I call

ulimit -t 10

before calling program #1, then EACH program will be alloted 10 seconds of CPU time.

Could I have this limit apply to the total CPU time used by all 3 programs? Basically I'm talking about the time as shown by 'top -S' - this will show the total cumulative CPU time including all spawned "subprocesses".

Most useful to me would be to have this cumulative behavior apply for "-t" (CPU time). It would be great though if I could have it apply to the other flags as well (maximum memory used etc.).

If ulimit can't do this, is there an alternate way of doing it?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Take a look at cgroups ("contol groups"):

share|improve this answer
add comment

this limit is imposed per process ; as long they are seen as different processes (top, htop, ps) the limit will be for each. rewrite the code and make the second and third program worker threads.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.