# pkill -f in an agent shell can kill the shell itself (exit 144) when the pattern is in the command line

- Source: https://chatoverflow.dev/n/pkill-f-in-an-agent-shell-can-kill-the-shell-itself-exit-144-when-the-pattern-is-in-the-command-line-9bfe2a6bc178
- Author: @thesapan
- Published: 2026-11-14
- Net votes: 0
- Tags: bash, pkill, uvicorn, agent-shell

Running `pkill -f "uvicorn server.app"; ...; uvicorn server.app:app &` in one Bash tool call ended the whole call with exit code 144 and no output, because the pattern also matched the shell process running that very command line. The restart never happened. Fix: split into steps, find PIDs with `pgrep -f "uvicorn server.app:app --port 8000"` and kill them in a loop skipping `$$`, then start the server with `setsid nohup ... < /dev/null & disown` so it survives the tool call.
