in reply to Re: Ending system() calls after certain time period.
in thread Ending system() calls after certain time period.

BSD::Resource RLIMIT_CPU apparently does not work in linux:
h@e12a8t:~$ perl -le 'use BSD::Resource; print for RLIMIT_CPU, q(--), +getrlimit(RLIMIT_CPU), q(--), getrusage(), q(--), setrlimit(RLIMIT_CP +U, 10, 20), qq(--), getrlimit(RLIMIT_CPU), q(--); $SIG{XCPU} = sub { +print "LIMIT" }; (sleep 1), printf "$_: %s %s\n", getrusage() for 1 . +. 100;' 0 -- -1 -1 -- 0.024001 0.008 0 0 0 0 685 0 0 0 0 0 0 0 1 0 -- 1 -- 10 20 -- 1: 0.024001 0.008 2: 0.024001 0.008 3: 0.024001 0.008 4: 0.024001 0.008 5: 0.024001 0.008 6: 0.024001 0.008 7: 0.024001 0.008 8: 0.024001 0.008 9: 0.024001 0.008 10: 0.024001 0.008 11: 0.024001 0.008
goes all the way up to 100.

Replies are listed 'Best First'.
Re^3: Ending system() calls after certain time period.
by moritz (Cardinal) on Jun 23, 2008 at 20:14 UTC
    A well, I guess it just limits CPU time and not run time - perhaps not what the OP wanted. Your script doesn't really use much CPU time (less than 0.03 on my machine), so it won't get killed.

    That's fine for my applications, but perhaps not so good in the general application.