[BUG] Bash tool intermittently emits child setpgid (...): Operation not permitted on macOS

Status Open
Reported on v2.1.258
Maintainer reply None cached
Activity 0 comments · opened Oct 14, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Description

Claude Code 2.1.258 intermittently emits the following warning during Bash tool execution on macOS:

child setpgid (...): Operation not permitted

The warning appears to be caused by Claude Code restoring interactive shell job-control settings into non-interactive Bash executions.

The issue has been reproduced independently of Claude Code.

Steps to reproduce

On macOS, run:

for i in {1..1000}; do
  bash -c 'set -o monitor; yq -n ".a=1" >/dev/null'
done

The warning occurs intermittently, approximately once every 300 iterations in the tested environment.

Root cause

Investigation indicates the following sequence:

  1. Claude Code captures the interactive shell state in ~/.claude/shell-snapshots/snapshot-bash-*.sh.
  2. The snapshot includes set -o monitor (job control), inherited from the interactive terminal.
  3. The Bash tool restores this option when executing non-interactive bash -c commands.
  4. With monitor mode enabled, Bash performs process-group management using setpgid() when launching external commands.
  5. On macOS, this can produce an intermittent EPERM error, apparently due to a race involving the child process.
  6. Bash prints the diagnostic to stderr.

The standalone reproduction establishes that enabling monitor mode is sufficient to trigger the warning without Claude Code being involved. The precise cause of EPERM has not been independently verified through system-call tracing.

Expected behavior

The Bash tool should not inherit interactive job-control settings that are inappropriate for non-interactive command execution.

Ordinary commands should execute without unrelated process-group diagnostics.

Actual behavior

The Bash tool intermittently emits child setpgid (...): Operation not permitted during otherwise successful command execution.

In the observed reproductions, commands completed successfully despite the warning. No functional failure has been demonstrated, although effects on process-group management and signal handling have not been ruled out.

Workaround

Disabling monitor mode prevents the warning:

set +m

This can be applied at the beginning of an affected Bash invocation.

Suggested fix

When restoring shell-state snapshots for non-interactive Bash tool execution, exclude or explicitly disable interactive job-control mode (monitor).

This should be handled centrally by Claude Code rather than requiring users to add set +m to individual commands.

Environment

  • Claude Code: 2.1.258
  • OS: macOS
  • Shell: Bash
  • Reproduction: Intermittent, approximately 1 in 300 iterations

Related issue

What Should Happen?

-

Error Messages/Logs

Steps to Reproduce

-

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.299

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗