Linux: get exit code from kill command

If I send a SIGTERM signal to a process using the kill command, I expect the exit code, but I always get 0 (zero) when I run the following command after the process is destroyed:

 echo $? 

According to the answer in this post, I should get 143 when sending SIGTERM to the process: Always terminate Java application with "Exit 143" Ubuntu

But I do not get the exit code. Why?

+7
source share
1 answer

The exit code you get is for the kill command itself. 0 means that it succeeded, that is, another process received a signal that you sent it. kill simply does not report the exit status for the process, since it cannot even be sure that another process exited due to the signal it sent.

+10
source

All Articles