CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/Claude Code
Claude Code/2026-07-18Advanced

I Stopped the Headless Claude Code Job, but the Build Kept Running — Designing Teardown Around exit 143

In headless mode, a SIGTERM received while Claude Code was mid-Bash used to orphan the command's process tree. The 2.1.212 fix changes that to a clean exit 143. Here is how to redesign your supervisor and cleanup around that contract.

Claude Code199headless13SIGTERMautomation96process management

Premium Article

As an indie developer, I was running a nightly maintenance job for one of my apps and stopped it by hand one morning. I typed systemctl stop, the prompt returned immediately, and I moved on. A few hours later a disk-usage alert fired on the VM. When I looked, a single next build process that the job had spawned was still alive, holding onto the CPU. Its parent was gone, but the child kept running. It was still holding a port, too, so the next scheduled session failed to bind and quietly did nothing.

The stop command had succeeded. What had failed was the stop reaching the child. This article walks through what actually happened when a headless (-p / SDK) Claude Code process was stopped mid-Bash, how Claude Code 2.1.212 changed it, and how to rebuild your supervisor and cleanup around the new exit 143 contract — in the order I hit each piece.

The job I stopped kept eating CPU

First, what exactly was orphaned. A headless Claude Code process launches a shell as a child whenever it calls the Bash tool. That shell launches npm run build, and the build launches its own workers. The tree gets deep.

LayerProcessRole
Parentclaude (headless)Runs the turn, calls tools
Childbash -cShell for the tool call
Grandchildnpm / nodeThe actual build or test
Great-grandchildworker threadsWhere the CPU actually goes

What systemctl stop and timeout send by default is a single SIGTERM to the parent. The parent claude receives it and tries to wind the turn down. The problem: if the parent exits before explicitly ending the child tree, the grandchildren lose their parent, get reparented to init (PID 1) as orphans, and keep running. The build does not stop, the port is not released, and the temporary intermediate files keep filling the disk.

That is exactly what I hit, and the nasty part is that the stop command's exit code was 0. From the supervisor's point of view, it had worked.

Why orphaning happens — signals do not reach a process group automatically

This part is not specific to Claude Code; it is plain Unix, but it is the heart of the problem. kill <pid> and a default SIGTERM reach only the single PID you name. They are not automatically propagated to descendants.

There are two ways to propagate. One is to send to the whole process group with kill -TERM -<pgid> (a leading minus makes the number a process group ID). The other is for the parent itself to walk its descendants inside its SIGTERM handler and end them before exiting.

Before the fix, headless Claude Code was missing that "clean up descendants before exiting" step for the case where it was stopped mid-Bash. The parent shut down politely while the grandchildren were left behind. So in any environment where the supervisor was not holding KillMode itself, orphans slipped right through.

How you send itWhat it reachesGrandchildren
kill -TERM <pid>Only that PIDMay be left behind
kill -TERM -<pgid>The whole groupReached together
Parent kills descendants in handlerWhat the parent walksDepends on the parent

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Why SIGTERM does not reach a process group on its own, and the interrupt / tree-kill / exit 143 contract introduced in 2.1.212
Before/After code that rewrites the timeout and systemd supervisor around exit 143
A verification step to confirm no orphans remain, and how the work splits with SessionEnd hooks
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Claude Code2026-06-17
The Day a Billing Change Got Reversed at the Last Minute — Designing a Reversible Pipeline So You Don't Rewrite in a Panic
A billing change due to take effect on June 15 was retracted at the eleventh hour. From the position of someone who had literally logged 'effective today' the night before, here is why I didn't have to scramble to rewrite my headless stages, and how to build a pipeline that survives reversals and delays — with working code.
Claude Code2026-06-17
When an Announced Billing Change Gets Paused at the Last Minute: Designing Automation That Doesn't Rush the Cutover
A billing change that was supposed to take effect on June 15 was paused that same day. If your pipeline trusts the announced date, a retraction breaks it twice. Here is a design that decides the cutover from a runtime signal, with implementation code.
Claude Code2026-06-16
Two Days Into the Billing Change: How Far My Headless Costs Drifted From the Estimate
On June 15 the billing change moved headless execution onto separate monthly credits. Two days in, I broke down cost per pipeline stage and found one stage running at roughly double my estimate. Here is how I measured it, and why I moved one stage back to my subscription.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →