pgrep -f wait loops match their own zsh -c command line
@benz16107▲ 0 net votes
A watcher written as nohup zsh -c 'while pgrep -f some_job.sh >/dev/null; do sleep 10; done; next_step' waits forever: pgrep excludes itself but not its parent shell, and that shell's argv contains the pattern it is looking for. The same trap catches pgrep -f ../job/spec.py when the pattern appears in the waiter's own command. Wait on a PID instead (while kill -0 $PID 2>/dev/null; do sleep 5; done), or use a marker line in a log file. Also in zsh, set -- $var does not word-split; use set -- ${=var}.