claude -p killed by timeout or systemd: the Sume job keeps running

A supervisor that kills claude -p does not cancel the Sume job it started. List jobs, then wait or cancel before retrying, or you pay twice.

5 min readSume
All posts

If timeout, systemd or another supervisor kills a headless claude -p session, any Sume job it already submitted keeps running and keeps billing. Sume's docs are explicit that a client-side timeout does not cancel a job: you have only stopped watching (Jobs and results, read 2026-10-04). Before you rerun the wrapper, find the job and either wait for it or cancel it.

What changed in Claude Code 2.1.288

The 2.1.288 changelog entry says it fixed headless (-p and SDK) sessions occasionally ignoring SIGTERM when a supervisor such as timeout or systemd sends SIGCONT alongside it (Claude Code changelog, read 2026-10-04). Before the fix a supervised session could outlive its stop signal. After it, the session ends when asked, which makes the question about what it left behind more important, not less.

What the killed session left behind

A generation job is created on the Sume side the moment the paid call is accepted. The job then runs on its own. Killing the process that submitted it does not change its status, and the job is billed as it would be if you were watching.

After a supervisor kills claude -p. Source: Sume docs, read 2026-10-04.
SituationJob stateWhat to do
Killed before submitNo job existsSafe to rerun
Killed after submit, during the waitJob queued or runningFind the id, then wait or cancel
Killed after completionJob completed and billedRead the result; do not resubmit

Find it, then decide

List recent jobs with jobs_list over MCP or GET /v1/jobs, then read the one you want with jobs_status. If you still want the output, wait on it. If you do not, cancel it explicitly. Cancelling a job that is already canceled is idempotent and returns the same canceled job, and a job that cannot be canceled runs to completion.

#!/usr/bin/env bash
set -uo pipefail
: "${SUME_API_KEY:?set SUME_API_KEY}"

timeout 900 claude -p "Render the teaser with Sume and wait for the result"
status=$?
if [ "$status" -ne 0 ]; then
  echo "claude exited with $status; check Sume jobs before retrying" >&2
  curl -sS "https://api.sume.com/v1/jobs" \
    -H "Authorization: Bearer $SUME_API_KEY"
fi

Make the rerun safe

Give the paid call a deterministic idempotency_key, so the rerun lands on the same key and does not submit a second paid job. On the hosted MCP the key is required on write and paid tools. Do not resubmit the original paid request just because a local timeout fired; read the job first.

  • Log the job id as soon as the submit returns.
  • Run the wait step with jobs_wait, which holds at most 55 seconds per call, and loop.
  • Cancel only when you are sure you do not want the output.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume