環境変数
CLAUDE_PID
Claude Codeが起動したサブプロセスに対し、自身のプロセスIDを通知する環境変数です。
使い方・用途
- Claude Code自身を誤って終了させることを防ぐための安全保護機能として利用されます。
- 自身のスクリプト内で親プロセスであるClaude Codeを識別したり、シグナルを送る際にも参照可能です。
英語原文(公式ドキュメントより)
Claude Code sets this to its own process ID in the subprocesses it spawns: Bash and PowerShell tool commands and hook commands. On Linux, the Bash tool's shell integration uses it to refuse a pkill pattern that would match the Claude Code process itself; see the error reference. Read it from your own scripts to identify or signal the parent Claude Code process deliberately. Requires Claude Code v2.1.214 or later