I run some processes via SSH from a remote client.
Sometimes the processes can be killed, with eg. kill. How to get the exit code/signal? The program is a PHP script
I run the script via sh -c so I can get the pid and ppid
sh -c 'echo $PPID; echo $$; php script.php'
Is it possible to listen/get the code from the parent process (sh -c)?
I can check if the pid is running, but if it has stopped I don't know if it completed with success, with an error or it was killed
I know you can use $? to get the exit code but would that work if the process was killed?
man 7 signaland https://unix.stackexchange.com/a/8918. – Quasímodo Nov 28 '20 at 23:11SIGKILLcannot be ignored, caught or blocked. The process will simply die, without being able to do anything about it. – Eduardo Trápani Nov 29 '20 at 01:41killI get code143? – clarkk Nov 29 '20 at 14:08kill -15gives143and if I usekill -9I get a bash error.. I don't think I can do anything about that? – clarkk Nov 29 '20 at 14:09