3

I'd like Apache to terminate my perl script after 1 minute if it doesn't complete naturally. Is there a setting in Apache (or other server software) to do this?

4 Answers 4

1

CGIwrap does much of the stuff that suEXEC does (run the script under alternate permissions), but it also allows you to set resource limits:

--with-rlimit-cpu=SECONDS
    limit cpu time with setrlimit
--with-rlimit-vmem=BYTES
    limit total virtual memory with setrlimit
--with-rlimit-as=BYTES
    limit total available memory with setrlimit
--with-rlimit-fsize=BYTES
    limit writable file size with setrlimit
--with-rlimit-data=BYTES
    limit data segment size with setrlimit
--with-rlimit-stack=BYTES
    limit stack segment size with setrlimit
--with-rlimit-core=BYTES
    limit core file size with setrlimit
--with-rlimit-rss=BYTES
    limit resident set size with setrlimit
--with-rlimit-nproc=COUNT
    limit number of processes with setrlimit
--with-rlimit-nofile=COUNT
    limit number of open files with setrlimit
--with-rlimit-memlock=BYTES
    limit lockable memory with setrlimit
0

Of the top of my head I can see two solutions (NOTE: I am a UNIX/Linux guy):

  1. Make modifications to your perl code to set an alarm and then program a signal processor to capture the alarm and perform whatever processing you want.

  2. You could manipulate the CPU limit of a process to terminate if it gets to 1 second CPU time. However, that real clock time length to get to 1 second of CPU time depends on your perl script.

0

This might help you: http://www.perlmonks.org/?node_id=703780

0

You could always put "alarm 60;" at the top of your Perl scripts. However, this would require modifying all your Perl programs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .