Wait Process to Finish
November 11, 2017
Cross platform solutution:
while kill -0 PID 2> /dev/null; do sleep 1; done;
Example:
$ sleep 60 &
$ while kill -0 $!; do echo 1 && sleep 0.5; done
If using FreeBSD:
pwait
Also lsoft
can be used but requires that the $pid
has open files:
lsof -p $pid +r 1 &>/dev/null