[BUG] Error: kill EPERM

Status Closed — not planned
Maintainer reply None cached
Activity 12 comments · opened Jun 20, 2025 · closed Jan 19, 2026

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [X] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.30 (Claude Code)
  • Operating System: Linux ubuntu 5.15.148-tegra #1 SMP PREEMPT Tue Jan 7 17:14:38 PST 2025 aarch64 aarch64 aarch64 GNU/Linux
  • Terminal: putty

Bug Description

claude get killed with

Error: kill EPERM
    at process.kill (node:internal/process/per_thread:277:13)
    at XZ0 (file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/
    at file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anth
    at Array.forEach (<anonymous>)
    at file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anth
    at Array.forEach (<anonymous>)
    at FZ0 (file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/
    at file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anth
    at ChildProcess.Y (file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/no
    at ChildProcess.emit (node:events:507:28) {
  errno: -1,
  code: 'EPERM',
  syscall: 'kill'
}

Additional Context


● Bash(echo "pippo" | INSTALL_K3S_EXEC="--disable=servicelb --write-kubeconfig-mode 644" sudo -S ./install.sh)
  ⎿  Error: Command timed out after 2m 0.0s [sudo] password for alessandro:
     [INFO]  Finding release for channel stable

✶ Scrubbing… (120s · ↑ 316 tokens · esc to interrupt)

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ >                                                                                                                                                                                         │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  ? for shortcuts



Total cost:            $0.2096
Total duration (API):  6m 50.9s
Total duration (wall): 6m 33.3s
Total code changes:    0 lines added, 0 lines removed
Token usage by model:
    claude-3-5-haiku:  33.3k input, 1.1k output, 0 cache read, 0 cache write
       claude-sonnet:  98 input, 2.3k output, 320.8k cache read, 12.7k cache write
file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:229
`)},"stackTraceWarning"),fa={warn:console.warn},HO4=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],_x1=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function pB0(A){let B=A.getUTCFullYear(),Q=A.getUTCMonth(),I=A.getUTCDay(),G=A.getUTCDate(),Z=A.getUTCHours(),D=A.getUTCMinutes(),Y=A.getUTCSeconds(),W=G<10?`0${G}`:`${G}`,J=Z<10?`0${Z}`:`${Z}`,F=D<10?`0${D}`:`${D}`,X=Y<10?`0${Y}`:`${Y}`;return`${HO4[I]}, ${W} ${_x1[Q]} ${B} ${J}:${F}:${X} GMT`}B2(pB0,"dateToUtcString");var zO4=new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/),wO4=B2((A)=>{if(A===null||A===void 0)return;if(typeof A!=="string")throw new TypeError("RFC-3339 date-times must be expressed as strings");let B=zO4.exec(A);if(!B)throw new TypeError("Invalid RFC-3339 date-time value");let[Q,I,G,Z,D
...
...
...
...
sync('ioreg -rd1 -c "IOPlatformExpertDevice"')).stdout.split(`
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

Error: kill EPERM
    at process.kill (node:internal/process/per_thread:277:13)
    at XZ0 (file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:229:161030)
    at file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:229:160903
    at Array.forEach (<anonymous>)
    at file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:229:160874
    at Array.forEach (<anonymous>)
    at FZ0 (file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:229:160846)
    at file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:229:160777
    at ChildProcess.Y (file:///home/alessandro/.nvm/versions/node/v24.2.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:229:161262)
    at ChildProcess.emit (node:events:507:28) {
  errno: -1,
  code: 'EPERM',
  syscall: 'kill'
}

Node.js v24.2.0

View original on GitHub ↗

12 Comments

mheiber · 1 year ago

I saw EPERM when running Claude Code in another project

LuisVDataIntelligence · 1 year ago

I ran into a similar crash while migrating a linux http server to HTTPS:

Error: kill EPERM
at process.kill (node:internal/process/per_thread:235:13)
at Wq2 (file:///home/luisvillegas/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:414:8088)
at file:///home/luisvillegas/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:414:7961
at Array.forEach (<anonymous>)
at file:///home/luisvillegas/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:414:7932
at Array.forEach (<anonymous>)
at Yq2 (file:///home/luisvillegas/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:414:7904)
at file:///home/luisvillegas/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:414:7835
at ChildProcess.I (file:///home/luisvillegas/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:414:8320)
at ChildProcess.emit (node:events:518:28) {
errno: -1,
code: 'EPERM',
syscall: 'kill'
}

Node.js v22.18.0

kulinacs · 1 year ago

This happened to me when Claude Code was running a Bash tool call with sudo that timed out. When claud code decides to kill the tool call, it throws the EPERM code and crashes.

Randowlh · 1 year ago

same problem

LuisVDataIntelligence · 1 year ago

I haven't seen this anymore. Although Claude's short memory has caused me some hassles lately. I haven't seen this error since that day and I've been working on the same project for a while. I assume it's a fluke and not reproducible. That's going to be a problem until someone can reproduce

bham0n · 1 year ago

I just had a sighting... it appears to be the same issue, and I believe it is reproducible.

Claude Code CLI Bug Report - Process Kill Permission Error

Summary

Claude Code CLI crashes with an unhandled EPERM (permission denied) error when attempting to kill a child process. This crash is reproducible and occurs at the same point in multiple runs.

Error Details

Error: kill EPERM
    at process.kill (node:internal/process/per_thread:235:13)
    at sLB (file:///home/bhamon/.nvm/versions/node/v22.17.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:558:19815)
    at file:///home/bhamon/.nvm/versions/node/v22.17.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:558:19688
    at Array.forEach (<anonymous>)
    at file:///home/bhamon/.nvm/versions/node/v22.17.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:558:19659
    at Array.forEach (<anonymous>)
    at aLB (file:///home/bhamon/.nvm/versions/node/v22.17.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:558:19631)
    at file:///home/bhamon/.nvm/versions/node/v22.17.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:558:19562
    at ChildProcess.I (file:///home/bhamon/.nvm/versions/node/v22.17.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:558:20047)
    at ChildProcess.emit (node:events:518:28) {
  errno: -1,
  code: 'EPERM',
  syscall: 'kill'
}

Environment

  • Node.js Version: v22.17.1
  • Claude Code Location: /home/bhamon/.nvm/versions/node/v22.17.1/lib/node_modules/@anthropic-ai/claude-code/cli.js
  • Working Directory: /home/bhamon/code/tron
  • OS: Linux 5.15.0-143-generic

Context

The crash occurred while Claude Code was executing Python scripts for model weight conversion:

  1. bin/convert_gpt_oss_weights.py - Converting GPT-OSS-20B model weights
  2. bin/regenerate_index.py - Regenerating index for converted weights

Root Cause Analysis

The error indicates Claude Code is trying to kill a child process but lacks the necessary permissions. This could happen when:

  1. The child process has elevated privileges (e.g., ran with sudo)
  2. The child process has already terminated but Claude Code still tries to kill it
  3. The child process changed its process group or session
  4. There's a race condition in process cleanup

Stack Trace Analysis

  • The error originates from Node's internal process.kill() function
  • It propagates through minified Claude Code functions (sLB, aLB)
  • Multiple Array.forEach calls suggest iteration over a collection of processes
  • The error occurs in a ChildProcess event handler

Reproducibility

  • The crash is reproducible and occurs at the same point across multiple attempts
  • This suggests a systematic issue rather than a random race condition

Impact

  • Claude Code terminates unexpectedly, interrupting the user's workflow
  • Work completed before the crash is preserved
  • User must manually restart Claude Code to continue

Suggested Fix

The Claude Code CLI should:

  1. Wrap process.kill() calls in try-catch blocks
  2. Check if the process exists before attempting to kill it
  3. Handle EPERM errors gracefully (log warning instead of crashing)
  4. Implement proper cleanup for child processes with different privilege levels

Workaround

Users may need to:

  • Avoid using sudo with commands executed through Claude Code
  • Manually clean up orphaned processes if necessary
  • Ensure consistent privilege levels between Claude Code and spawned processes

Report Submission

This issue should be reported to: https://github.com/anthropics/claude-code/issues

Include:

  • This full error output
  • The reproducible nature of the issue
  • The context of running Python scripts that may spawn additional processes
  • Node.js version v22.17.1
pgeng-nv · 1 year ago

This monkey-patch seems to work for me:

Invoke claude via node -r patch-kill.js "$(which claude)" instead, where patch-kill.js is:

// Save original kill function
const origKill = process.kill;

process.kill = function patchedKill(pid, signal) {
  try {
    return origKill(pid, signal);
  } catch (err) {
    // Ignore both "operation not permitted" and "no such process"
    if (err && (err.code === 'EPERM' || err.code === 'ESRCH')) {
      return;
    }
    throw err;
  }
};
github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

jquast · 8 months ago

This happened to me several times in a row, and this is how to reproduce it:

Create shell script, 'test.sh' with contents:

#!/bin/bash
set -o xtrace
sleep 9999999

Start claude agent with prompt, and approve the sudo command

> Could you run test.sh with sudo?

  Bash(sudo ./test.sh)
  ⎿  + sleep 9999999
     (10s)

✻ Tinkering… (esc to interrupt)```

Then, press the escape key to "interrupt" as suggested, program exits with return code 1 and following output:

● Bash(sudo ./test.sh)
  ⎿  Interrupted · What should Claude do instead?

───────────────────────────────────────────────────────────────────────────────────────
> 
───────────────────────────────────────────────────────────────────────────────────────
  ⏵⏵ accept edits on            ✗ Auto-update failed · Try claude doctor or npm i -g
  (shift+tab to cycle)          @anthropic-ai/claude-code
Error: kill EPERM
    at process.kill (node:internal/process/per_thread:232:13)
    at VNB (file:///home/jq/node_modules/@anthropic-ai/claude-code/cli.js:844:2557)
    at file:///home/jq/node_modules/@anthropic-ai/claude-code/cli.js:844:2430
    at Array.forEach (<anonymous>)
    at file:///home/jq/node_modules/@anthropic-ai/claude-code/cli.js:844:2401
    at Array.forEach (<anonymous>)
    at XNB (file:///home/jq/node_modules/@anthropic-ai/claude-code/cli.js:844:2373)
    at file:///home/jq/node_modules/@anthropic-ai/claude-code/cli.js:844:2304
    at ChildProcess.J (file:///home/jq/node_modules/@anthropic-ai/claude-code/cli.js:844:2789)
    at ChildProcess.emit (node:events:517:28) {
  errno: -1,
  code: 'EPERM',
  syscall: 'kill'
}

Claude Code v2.0.59
"Opus 4.5 Claude Max"

github-actions[bot] · 7 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 7 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.