[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Limiting the CPU time of program started via SYSTEM

Gene Tani

6/15/2005 2:32:00 PM

never used it, but i did notice "rlimit" port in RPAbase with
#getrlimit

Tanaka Akira wrote:
> In article <97880ae0506141918e56d386@mail.gmail.com>,
> Garance A Drosehn <drosihn@gmail.com> writes:
>
> > Let's say I have a ruby script which calls system() to run some
> > arbitrary program. Since that program might spiral off into some evil
> > infinite-loop, is there some way for me to say "execute this, but for
> > no longer than 2 seconds of CPU time"? In the C-world I might use
> > something like setrlimit, but I'm not sure how easy that would be to
> > do from within a ruby script.
> >
> > Note that I don't want to limit the CPU time of the script itself. I
> > just want to limit the CPU time for specific applications that I
> > execute via system().
>
> Ruby 1.9 has Process.setrlimit (and Process.getrlimit).
>
> % ruby -e 'Process.wait fork { Process.setrlimit Process::RLIMIT_CPU, 2, 2; exec "yes > /dev/null" }'
> --
> Tanaka Akira