in reply to use less 'CPU'

Erm, perhaps you'd want to look into BSD::Resource, which will let the OS do more of the monitoring rather than polling yourself (at least that's what resource control: CPU looks to be doing).

Not that a more pragmatic interface than setrlimit would be a bad thing.

Replies are listed 'Best First'.
Re: Re: use less 'CPU'
by powerman (Friar) on Feb 13, 2003 at 20:19 UTC
    No, BSD::Resource and setrlimit don't allow to control max CPU load. They allow only control max cpu time. I.e. with my feature script may run forever, but never take more than 40% CPU. With setrlimit (or ulimit in bash) you can limit script to 5 CPU minutes and after script reach this limit kernel will kill it.

      The default SIGXCPU handler dies, but there's nothing stopping you from installing your own handler which does something different (sleeps, alters what's running, sets a different limit).