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?