shell - exit code when crashed -


I like to know whether the app has crashed or not from a shell script. What will be the exit code if the application crashes?

The exhaust code of the application will be in the shell variable $? If your app crashes, that means the operating system decides that it has done something bad, and the reason for it to end (it sends a signal), then it $?

Here is a simple function I use (in bash I have set it as PROMPT_COMMAND variable) puts some decoding of exit status

  check_exit_status () {local status = "$?"; Local msg = ""; Local sign = ""; If [$ {status} -ne 0]; Then if [$ (($ {status} & lt; 128)) -a 0]; Then msg = "exit ($ {status})"; Other sign = "$ (baltin kill- l $ (($ {status} - 128) 2) gt; / dev / null;; if [" $ sign "]; then msg =" kill - $ sign $ msg "; Fi; fi; echo "[$ {status} => $ {message}]" 1> and 2; fi; return 0}   

Hope you find it useful Find

Comments