Bug report
File: .claude/skills/claw/scripts/claw
Summary
When the closing sentinel ---NANOCLAW_OUTPUT_END--- is detected in the container's stdout, the script calls proc.kill() to terminate the container early (to avoid the Node.js event loop keeping it alive). However, proc.kill() causes the subprocess to exit with a non-zero return code. Later, when the script reads status == "success" from the structured JSON output, it still propagates the container's non-zero return code to the caller — making a successful claw invocation look like a failure to shell scripts and CI pipelines.
Reproduction
claw "What is 2+2?"
echo $? # prints non-zero even on a successful response
Root cause
In run_container(), the sentinel handling does:
if line.strip() == "---NANOCLAW_OUTPUT_END---":
done.set()
try:
proc.kill() # ← SIGKILL → non-zero exit code
And the exit-code propagation at the end of main() does not distinguish between a kill-induced non-zero and a real container failure, so a status=success response still causes claw to exit non-zero.
Suggested fix
Two complementary changes:
- Graceful shutdown on sentinel — replace
proc.kill() with proc.terminate() (SIGTERM) followed by proc.wait(timeout=5) so the container can exit cleanly with code 0.
- Exit-code override on success — after confirming
status == "success", return early (before any sys.exit based on the container return code) so the script always exits 0 on a successful response, regardless of how the container process ended.
References
Reported by @taslim.
Bug report
File:
.claude/skills/claw/scripts/clawSummary
When the closing sentinel
---NANOCLAW_OUTPUT_END---is detected in the container's stdout, the script callsproc.kill()to terminate the container early (to avoid the Node.js event loop keeping it alive). However,proc.kill()causes the subprocess to exit with a non-zero return code. Later, when the script readsstatus == "success"from the structured JSON output, it still propagates the container's non-zero return code to the caller — making a successfulclawinvocation look like a failure to shell scripts and CI pipelines.Reproduction
Root cause
In
run_container(), the sentinel handling does:And the exit-code propagation at the end of
main()does not distinguish between a kill-induced non-zero and a real container failure, so astatus=successresponse still causesclawto exit non-zero.Suggested fix
Two complementary changes:
proc.kill()withproc.terminate()(SIGTERM) followed byproc.wait(timeout=5)so the container can exit cleanly with code 0.status == "success", return early (before anysys.exitbased on the container return code) so the script always exits 0 on a successful response, regardless of how the container process ended.References
Reported by @taslim.