It's just what the question asks. Also, all I have is the PID, and the shell I am running the command from is not necessarily the shell that initially invoked the process. Any ideas?
while ps -p $PID >/dev/null 2>&1; do sleep 1; done
or
while ps -p $PID >/dev/null 2>&1; do :; done
It's not a very neat way to do it, but you may continuously issue kill(2) system calls to the specified pid, putting zero as a signal. The first time kill doesn't succeed by setting errno to ESRCH, you may conclude that the process has exited.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With