Hello Davious,
The specific definition of "soft" and "hard" limit may vary with the
operating system you are using. However, the basic definition for
these terms come from Unix (or Linux) systems. For example, searching
for
man rlimit
provides a variety of references to the functions
getrlimit
setrlimit
Using
http://www.hmug.org/man/2/setrlimit.html
as an example, scroll down to the explanation of both soft and hard
limits. Specifically it states
A resource limit is specified as a soft limit and a hard limit. When a
soft limit is exceeded a process may receive a signal (for example, if
the cpu time or file size is exceeded), but it will be allowed to contin-
ue execution until it reaches the hard limit (or modifies its resource
limit).
The CGI process generally cannot increase the hard limit (there IS an
exception for the "root" user).
From what you describe the CGI process appears to be "killed" by the
signal being delivered by exceeding the soft resource limit. If you do
not have a signal handler, the default action indicated in this
reference
http://www.hmug.org/man/2/sigaction.html
is that the process be killed. In other words, Apache sets the hard
and soft resource limits for the process running the CGI and the limit
will then be enforced by the operating system.
In the reference I used - it states that SIGXCPU is the signal
delivered. If your CGI is written in C (or a similar language) you can
set up a signal handler. The signal handler can then set a flag
indicating the soft limit is exceeded and resume execution. This
allows the main loop of your CGI to take action when this occurs. If
you want to follow up on this alternative, let me know the language so
I can see if you can apply this approach to your CGI and suggest some
methods to implement it.
I provided references for a BSD based system (Mac OS X), but the
behavior is similar in other Unix and Linux systems. For example:
http://www.die.net/doc/linux/man/man2/getrusage.2.html
describes the similar functions in Linux where the process continues
to get SIGXCPU once a second after exceeding the soft limit (or until
it reaches the hard limit). If it reaches the hard limit, SIGKILL is
delivered (which cannot be stopped).
If you use Microsoft Windows, it appears that Services for Unix also
supports this type of implementation. See
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/itsolutions/interop/unix/sfu/Sfuport.asp
for a description of this support.
As mentioned above, if you are looking for a way to handle the soft
limit within the CGI, please indicate the language being used in a
clarification request. I should be able to describe how to to set up
the signal handler (if feasible).
--Maniac |