So recently I've noticed that I have a process that will randomly crash and become a zombie with a PPID of 1 (init). I've been told that the only way to fix this is to reboot the PC (or send SIGCHLD to init, which is....dicey/useless, from what i understand. )
Essentially, what I'm looking to do is write a bash script that will just look for a zombie process and if there is one, reboot the PC.
Currently, i use this script to monitor the process itself:
ps auxw | grep ethminer | grep -v grep > /dev/null
if [ $? != 0 ]
then
sudo reboot
fi
Now, this script seems to work fine when ethminer is either RUNNING, or NOT RUNNING; it will reboot the machine if it does not see ethminer in the process table, and it does nothing if it doesn't see it.
However, (from my admittedly loose understanding) since there is no exit code when the process becomes a zombie if [ $? != 0 ] doesn't get any input, and therefore doesn't do anything.
Is there anyway I can fix/modify this script so it does what i want it to do? Or am I way off track here?
Thanks!