I'm writing a shell script that called some programs that can use up all resources and effectively kill a machine. I must prevent this some happening.
My idea was to use ulimit to set resource limits (first time I've ever actually needed to use ulimit in practice) but I was a little surprised that the exit status of a killed process is 0.
How can my shell scripts limit resources AND detect a process being killed by the shell because it exceeded that limit?
I'm using bash but any comments would be worth reading.