Skip to navigation

Kill a background command

Ends a background command and the processes it left running, and returns its final state. Safe to call twice, and safe on a command that has already ended: the call then returns that command’s final state unchanged and still ends what it left running.

What is ended: every process that carries the command’s environment variable MEADOW_EXEC_ID, which children inherit, and, while one of those is still in the command’s session, every other process in that session. A child in the command’s process group, one that started its own session with setsid, and one that cleared its environment but stayed in the session are all ended. A process that cleared its environment and also left the session cannot be told apart from others and is not ended. TERM is sent first, KILL after 2 seconds.

The returned stdout and stderr are empty and the offsets are 0. Read the output with GET /v1/sandboxes/{sandbox_id}/execs/{exec_id}.

If Meadow cannot confirm that the command ended, the call returns 502. Call it again.

Scope: sandboxes.

Authentication

AuthorizationBearer

A Meadow API key, sent as Authorization: Bearer mdw_.... The header x-api-key: mdw_... is accepted in its place.

Path parameters

sandbox_idstringRequired

The sandbox id returned by POST /v1/sandboxes. It must belong to the key’s project.

exec_idstringRequired

The id returned when the background command was started.

Response headers

x-request-idstringOptional

Meadow’s id for this request, req_ and 24 hex characters. Every response carries it, including errors, streams and unknown routes. Every error in the Error schema repeats it as request_id. Quote it when you report a problem.

Response

The command's final state.
idstring
The command id.
statusenum
  • running: still going.
  • exited: ended on its own. Read exit_code.
  • killed: ended by the kill call. killed with a null exit_code means the sandbox was deleted or timed out before the command ended.
  • timed_out: killed at timeout_seconds.
  • failed: Meadow could not learn how the command ended. failure_reason says why. This value is new (2026-11-24): a client with a fixed list of statuses must add it, and should treat any status other than running as final.
Allowed values:
failure_reasonenumOptional

Set when status is failed.

  • state_lost: the command’s state inside the sandbox (its files under /tmp/.meadow-exec, or the process that supervises it) was gone for more than 2 minutes, so the exit code is unknown and exit_code is null. The command itself may have finished.
  • sandbox_lost: the vendor lost the sandbox while the command was running. The sandbox reads failed with failure_reason provider_lost. This value is new (2026-11-24). These commands read killed with a null exit_code before.
  • provider_unreachable: for 10 minutes the vendor answered “not found” or “not running” on every call about this command while it reported the sandbox as running. Meadow stopped tracking this one command. Other commands and the sandbox are not changed. The command itself may still be running. New on 2026-11-24.

More values can be added. Treat one you do not know as an unknown outcome.

Allowed values:
exit_codeinteger or nullOptional
The exit code. Null while running, and when the outcome is unknown.
stdoutstringOptional

Output from stdout_offset onward. Empty in the start and kill responses.

stderrstringOptional

Error output from stderr_offset onward. Empty in the start and kill responses.

stdout_offsetintegerOptional

The byte offset after the returned stdout. Pass this on the next read.

stderr_offsetintegerOptional

The byte offset after the returned stderr. Pass this on the next read.

stdout_truncatedbooleanOptional

True when the command wrote more than 16 MiB to stdout and only the first 16 MiB is kept, or when this read is served from the part Meadow keeps after the sandbox ended and it starts later than the offset you asked for. Absent otherwise.

stderr_truncatedbooleanOptional

True when the command wrote more than 16 MiB to stderr and only the first 16 MiB is kept, or when this read is served from the part Meadow keeps after the sandbox ended and it starts later than the offset you asked for. Absent otherwise.

started_atdatetimeOptional
When the command started.
finished_atdatetime or nullOptional
When the command ended. Null while running.

Errors

401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
429
Too Many Requests Error
500
Internal Server Error
502
Bad Gateway Error