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

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -