shell - ulimit returns 0 as exit status... how to get 1 if process killed? -


i'm writing shell script called programs can use resources , kill machine. must prevent happening.

my idea use ulimit set resource limits (first time i've ever needed use ulimit in practice) little surprised exit status of killed process 0.

how can shell scripts limit resources , detect process being killed shell because exceeded limit?

i'm using bash comments worth reading.

a program exceeding 1 of ulimits either terminate due error (e.g. out of file descriptors, processes) or catch signal (memory, cpu time). means test exit status of program in question.

ulimit ... program xs=$? case $xs in  0) ;; # fine  *) if [ $xs -gt 127 ];        echo caught signal...     else        echo error...     fi esac 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -