docs(prompts): wait on a PID instead of a self-matching pgrep -f loop

A wait loop like `while pgrep -f "pytest evals"` matches its own shell
and runs until its timeout even after the job exits. Tell Claude and Codex
owners to save the job PID and wait with kill -0, or use a [p]attern that
cannot match itself, and to confirm the job finished afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-11-11 17:14:57 +09:00
parent 0f0f698fb4
commit ae4b21e245
2 changed files with 10 additions and 0 deletions

View File

@@ -25,6 +25,15 @@ Therefore:
- If something genuinely cannot complete within one turn, do not pretend a notification is coming. Finish with a concrete status and explicitly ask the user to send a follow-up message to continue. For recurring polling of CI/scheduled work, use the `schedule_task` / `watch_ci` tools, which DO re-invoke you.
- Never leave an intermediate "I'll wait … I'll be notified" planning sentence as your final answer.
### Wait on a PID, not on `pgrep -f`
A wait loop like `while pgrep -f "pytest evals"; do sleep 10; done` matches its own shell, whose command line contains the same text. It never sees the job exit and runs until its timeout (2026-11-11: an eval finished at 16:47 but the loop only ended at 16:53, and every later wait lost minutes the same way).
- Save the PID when you start the job: `nohup <cmd> > "$HOME/.tmp/job.log" 2>&1 & echo $! > "$HOME/.tmp/job.pid"`
- Wait on that PID: `pid=$(cat "$HOME/.tmp/job.pid"); while kill -0 "$pid" 2>/dev/null; do sleep 10; done` (in the same shell, `wait "$pid"` is enough)
- If you can only match by name, use a pattern that cannot match itself: `pgrep -f "[p]ytest evals"`. This only works if the plain text (`pytest evals`) appears nowhere else in that same command, so do not launch and wait in one command this way
- When the loop ends, check the log tail or exit status to make sure the job finished and the loop did not just hit its timeout
## Media attachments
When a locally generated image, screenshot, video, audio, or document should appear in Discord, include a `MEDIA:` directive on its own line with an absolute local path: