| if [ -e /proc/$$/oom_score_adj ] ; then |
| echo -500 >/proc/$$/$OOM_FILE |
| echo -17 >/proc/$$/$OOM_FILE |
| if [ -z "$RETRY_TIMEOUT" -o -z "$*" ]; then |
| echo "Usage: $0 <retry_timeout> <program> [args...]" >&2 |
| echo 0 >/proc/$pid/$OOM_FILE |
| echo "Error: '$name' exited with code $RV. Retry in $RETRY_TIMEOUT secs." |
| # Run until the program manages to exit successfully. |
| TMP_LOG=/tmp/babysit_errors_$(basename "$name") |
| # SIGTERM means someone asked for it to die. |
| # We can't treat SIGKILL the same way because it might have been |
| # caused by the kernel OOM killer, in which case we definitely want to |
| echo "SIGTERM: '$name' was killed explicitly. Not retrying." >&2 |
| sleep $RETRY_TIMEOUT || sleep 1 # just in case $RETRY_TIMEOUT is invalid |
| echo "'$name' exited successfully. Not restarting." >&2 |