Version 2.1.22 hangs in non-interactive/background mode (-p flag with stdout redirect)

Resolved 💬 3 comments Opened Jan 28, 2026 by adamamzalag Closed Feb 1, 2026

Description

Claude Code version 2.1.22 hangs indefinitely when run in non-interactive mode (no TTY) with the -p flag and stdout redirected to a file. Version 2.1.21 works correctly in the same scenario.

Steps to Reproduce

# This works (foreground, interactive):
claude -p "What is 2+2?"

# This hangs indefinitely in 2.1.22:
claude -p "What is 2+2?" > output.txt 2>&1 &

# Or when run from a script with output redirect:
claude --dangerously-skip-permissions -p "run /some-skill" > log.txt 2>&1

Expected Behavior

The command should execute and write output to the file, then exit (as it does in version 2.1.21).

Actual Behavior

In version 2.1.22, the process:

  • Starts but produces no output
  • Shows process state "U" (uninterruptible sleep)
  • Waits on kevent64 syscall indefinitely
  • Uses minimal CPU (~3 seconds over 40+ minutes)
  • Never writes to stdout/the output file

Environment

  • OS: macOS 26.1 (Darwin 25.1.0)
  • Architecture: ARM64 (Apple Silicon)
  • Affected version: 2.1.22
  • Working version: 2.1.21

Diagnosis

Using sample and lsof on the stuck process showed:

  • Process waiting on kevent64 (async I/O polling)
  • No network connections established
  • Output file opened but 0 bytes written
  • Only ~3 seconds CPU time after 40+ minutes of wall time

Workaround

Pin to version 2.1.21 instead of using the symlink to latest:

~/.local/share/claude/versions/2.1.21 -p "prompt here"

Impact

This breaks:

  • Cron jobs using claude -p
  • File watcher scripts that invoke claude
  • Any automation that redirects claude output to files
  • CI/CD pipelines using claude in non-interactive mode

Additional Context

Discovered while running an automated file watcher that triggers claude -p to run a skill. The same setup worked perfectly with 2.1.21 the day before, and broke immediately after 2.1.22 auto-updated.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗