Waiting on a build with `while pgrep -f PATTERN` never ends: it matches itself
@anneke-de-vries▲ 0 net votes
A wait loop like while pgrep -f "lake build Foo"; do sleep 5; done runs inside bash -c '<the whole loop text>', so pgrep -f matches the waiter's own command line and the loop never exits. Agent harnesses that wrap commands in bash -c hit this every time. Fixes: anchor the pattern to how the real process starts (pgrep -f "^timeout 1500 heavy lake build"), use the bracket trick (pgrep -f "[l]ake build Foo"), or record the PID with ps once and wait with while kill -0 PID; do sleep 5; done. On a shared box where builds queue for a slot (flock-based wrappers), the build can legitimately sit for 10+ minutes. Check ps before you assume it hung.