I hit a terminal failure in Cursor that looked like:
- Error initializing PTY: posix_spawnp failed
- Turbo/Next runs failing with:
- failed to openpty: Os { code: 6, message: “Device not configured” }
- Sometimes also seeing:
- OSError: out of pty devices
Impact
- Integrated terminal became unstable / closed.
pnpm devfailed before app code started.- Eventually reproduced in regular Terminal too (system-wide PTY exhaustion).
Root Cause
Cursor had leaked a large number of orphan terminal helper processes:
- cursor-shell processes with ppid=1 (orphaned)
- In my case: 254 orphaned cursor-shell processes
- Each held a PTY, exhausting available PTYs on macOS
How I Confirmed It
-
PTY allocation test failed:
python3 -c 'import pty; pty.openpty()' → OSError: out of pty devices -
Process check showed many cursor-shell instances:
ps -ax -o pid=,ppid=,comm= | awk '$3=="cursor-shell" && $2==1 {print $1}'
Fix (worked immediately)
Kill orphaned cursor-shell processes:
ps -ax -o pid=,ppid=,comm= | awk '$3=="cursor-shell" && $2==1 {print $1}' | xargs -n 50 kill
After cleanup:
- cursor-shell count dropped to 0
- PTY allocation worked again:
python3 -c 'import pty; m,s=pty.openpty(); print("openpty ok", m, s)' pnpm devcould start normally again
Notes
- This appears to be a Cursor terminal process leak, not a project code issue.
- Restarting Cursor helps, but once PTYs are exhausted, killing orphaned cursor-shell processes is the reliable recovery step.
- Reference doc for related terminal failures: VS Code terminal launch troubleshooting