Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

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

share|improve this answer

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
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.