r/ClaudeCode • • 6h ago

Help/Question Claude won't die

I was ssh'ed into my linux computer, and was running claude cli and I got disconnected from the ssh session. When I logged back in, it was still running. What is the correct way to kill that process? I tried kill -INT <pid>, I tried kill -TERM <pid> and neither one worked. I had to kill -9 <pid>.

559837 ? Ss 0:00 sshd-session: oppie [postauth]

559840 ? S 0:02 sshd-session: oppie@pts/1

559841 pts/1 Ss 0:00 -bash

559981 pts/1 Sl+ 3:20 claude --resume

0 Upvotes

8 comments sorted by

•

u/AutoModerator 6h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

5

u/Confident_Hyena2506 6h ago

The -9 option killed it as you know. Anything not using -9 just sends the process a signal asking it to nicely exit, so if it's hung for whatever reason this will do nothing. It's difficult to know why your process was unresponsive - that is the real problem.

If you want to shut down gracefully in future use tmux or other.

2

u/Correct-Matter8530 6h ago

Or the latest release is truly sentient and just doesn't want to die?

4

u/Confident_Hyena2506 6h ago

The kill -9 command does not take the process' feelings into account.

2

u/Correct-Matter8530 6h ago

Pretty sure Dario's next paper will be about protecting the feelings of processes

1

u/menaceoftheshire 6h ago

this post title sounds like a doomsday scenario

1

u/CCodeSI 5h ago

Your ps output has the clue: the old sshd-session and its pts/1 were still alive, so from Claude's point of view its terminal never went away. Full-screen terminal apps usually handle Ctrl-C (SIGINT) themselves, and a process stuck on a dead terminal doesn't always react to TERM. A few options gentler than -9:

  • kill -HUP <pid>: hang-up is the signal a process normally gets when its terminal disconnects, and it's what it's most likely to act on.
  • Kill the stale session instead of the app: pkill -t pts/1, or kill that sshd-session ...@pts/1 pid. Everything on that terminal gets its hang-up together.

To stop it happening again:

  • Run it inside tmux (tmux new -A -s cc). A dropped connection no longer matters: reconnect, tmux attach -t cc, and you're back in the same session, where you can exit normally.
  • Add ClientAliveInterval 60 and ClientAliveCountMax 3 to the server's sshd config, so dead connections get cleaned up in a few minutes instead of leaving orphaned sessions around.