I was thinking about doing this. However, this would mean that the process would stay active, and I don't want that. Should be simple enough to do. I considered doing a slight wait, maybe a second or less, but considering this is actually going to be used in a CGI, not a good idea.
You could use something similar to this to check if there are enough resources for a heavy task, and keep checking, with a maximum wait time...
| [reply] |
Response: Yes, the process would stay active, but isn't that what's needed, at least until the script ends, or the process is terminated? My guess would be to fork this check. I'm uncertain why there aren't any hooks already into the Linux kernel to do this... perhaps there are, afterall, I come from the MS world :)
Demize
| [reply] |
Well, if this script is being called only once, such as with a cron job, that's fine. However, if you were to put this into a CGI script, the number of processes or memory could quickly get out of control. You could add a check to see how many processes are running under the user. Then you could kill it (or something else that's cleaner) if there are too many processes, or too much memory is used. This might be the best of both worlds.
| [reply] |