---
title: "Discussion on \"pkill -f cat quits every app on a Mac, and coding agents keep running it\" | Hashnode"
description: "Discussion on \"pkill -f cat quits every app on a Mac, and coding agents keep running it\". Three open issues on the Claude Code repository describe the same event. An agent wants to stop one stuck cat process, it runs something like pkill -f 'cat' -n -u 501 2>/dev/null, and a second later S"
url: "https://hashnode.com/posts/pkill-f-cat-quits-every-app-on-a-mac-and-coding-agents-keep-running-it/6af57f79de1309ac2b76f679"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [pkill -f cat quits every app on a Mac, and coding agents keep running it](https://dooly6276.hashnode.dev/pkill-f-cat-quits-every-app-on-a-mac-and-coding-agents-keep-running-it?utm_source=hashnode&utm_medium=feed)

Three open issues on the Claude Code repository describe the same event. An agent wants to stop one stuck cat process, it runs something like pkill -f 'cat' -n -u 501 2>/dev/null, and a second later S

18h ago · 6 min read · dooly6276.hashnode.dev  
Read the article

-   [#claude-code](https://hashnode.com/tag/claude-code)
-   [#macos](https://hashnode.com/tag/macos)
-   [#ai](https://hashnode.com/tag/ai)
-   [#shell](https://hashnode.com/tag/shell)

## Written by

[Myeongseok Kang](https://hashnode.com/@dooly6276)

@dooly6276

  
[View profile](https://hashnode.com/@dooly6276)

## Responses 6

Markdown supported · ⌘↵ to post

[Apps by Mo](https://hashnode.com/@appsbymo)

[14h ago](https://hashnode.com/posts/pkill-f-cat-quits-every-app-on-a-mac-and-coding-agents-keep-running-it/6af57f79de1309ac2b76f679/comment/6af5bc3fec18926cf0d16c87)

This exact one hit me on 25 October. An agent cleaning up after a build ran pkill -f “cat” and every menu bar app I had open quit, along with a long job in another app and the agent itself. What has held since: every brief I give an agent that runs background jobs says “stop only by the PID you saved from $!”, and it may never quit anything it did not start. For putting things back, open -g -a relaunches each app without stealing focus, and pgrep -x confirms it is up. The option-order point is new to me, thanks for measuring it.

[Myeongseok Kang](https://hashnode.com/@dooly6276)

[13h ago](https://hashnode.com/posts/pkill-f-cat-quits-every-app-on-a-mac-and-coding-agents-keep-running-it/6af57f79de1309ac2b76f679/comment/6af5bc3fec18926cf0d16c87#reply-6af5cad61942362d106e68f1)

Thanks for writing this up. The agent quitting along with everything else is the worst part of it, because then nothing is left to say what happened. "Stop only the PID you saved from $!" is the same rule the hook falls back to, and it is good to hear it holds in a written brief too, with nothing enforcing it. open -g -a to put the apps back without stealing focus, then pgrep -x to check, is a useful recovery step.

[Vic Moreno](https://hashnode.com/@itsvicmoreno)

[18h ago](https://hashnode.com/posts/pkill-f-cat-quits-every-app-on-a-mac-and-coding-agents-keep-running-it/6af57f79de1309ac2b76f679/comment/6af5829fd5a89663b96369a1)

The trap is that -f matches the whole command line, and every app path on a Mac contains /Applications/, which contains "cat". Running pgrep -fl with the same pattern first shows the blast radius before anything dies. Did any of the three issues get a fix, or is it still on the user to block pkill -f in a hook?

[Myeongseok Kang](https://hashnode.com/@dooly6276)

[18h ago](https://hashnode.com/posts/pkill-f-cat-quits-every-app-on-a-mac-and-coding-agents-keep-running-it/6af57f79de1309ac2b76f679/comment/6af5829fd5a89663b96369a1#reply-6af584c5b354e8da918b3dbb)

Thanks. All three are still open as of today (anthropics/claude-code #100684, #107867 and #90070), so for now it is still on the user. The hook in the post is the smallest version of that: it refuses pkill -f when pgrep -fl with the same pattern finds a process inside a .app bundle, and tells the agent to kill by PID instead. bulkhead 0.3.5 does the same check and also refuses patterns that reach 8 or more processes outside the calling session.

[Vic Moreno](https://hashnode.com/@itsvicmoreno)

[18h ago](https://hashnode.com/posts/pkill-f-cat-quits-every-app-on-a-mac-and-coding-agents-keep-running-it/6af57f79de1309ac2b76f679/comment/6af5829fd5a89663b96369a1#reply-6af585c373a1ddcf55c9bccc)

Refusing on a match inside a .app bundle is the right test, much tighter than a plain pkill block. Kill by PID also leaves a clear trail in the transcript. Does the 8-process threshold in bulkhead count child processes of the calling session, or only its direct children?

[Myeongseok Kang](https://hashnode.com/@dooly6276)

[13h ago](https://hashnode.com/posts/pkill-f-cat-quits-every-app-on-a-mac-and-coding-agents-keep-running-it/6af57f79de1309ac2b76f679/comment/6af5829fd5a89663b96369a1#reply-6af5ca9233d3ec5b7c4bc25e)

The whole tree. bulkhead walks down from the calling session's Claude Code process and treats every descendant as that session's own: the shell, a dev server started from it, and the server's workers, at any depth. Those are left out of the count. Everything else the pattern matches counts toward the 8, including other sessions' processes and unrelated programs. A child is only accepted if it started after its parent, so a reused PID on Windows does not pull an unrelated process into the tree, and on Linux a server that outlived its shell is still matched to its session through CLAUDE\_PID in its environment.
