Process groups and trees
Every process axed starts leads its own process group. A process on a terminal also leads its own session. Children it starts join that group unless they create their own, as a shell with job control orsetsid does.
When axed manages a delegated cgroup v2 tree, each process also gets its own cgroup, which holds every descendant no matter what group or session it joins. axectl info shows the cgroup, or - without one. Containers and hosts explains how to give axed a cgroup.
Send a signal
Processes.Signal delivers any positive signal number to the process group. Set leader_only to signal only the process you started; axed then uses a pidfd, so the signal cannot reach a recycled pid. Once the process you started has exited, a signal succeeds and does nothing, even while axed is still collecting its output, so it never reaches a process that has since reused the pid or its group id.
- axectl
- gRPC
-s takes a number or one of HUP, INT, QUIT, KILL, USR1, USR2, TERM, STOP, CONT and WINCH. Names are case-insensitive, and the SIG prefix is optional: TERM, term, SIGTERM and sigterm all work. axectl kill always signals the group.The Agent Sandbox
SendSignal accepts only SIGINT, SIGTERM and SIGKILL, and always signals the group.Kill a whole tree
A signal reaches only the process group. Descendants that left the group, or that ignore the signal, survive it. axed kills the whole tree withSIGKILL when:
- a timeout expires,
- you remove a running process with
Processes.Removeandkill: true(axectl rm -f), - the stream of an attached
Run(withoutdetach) or anExeccall ends before the process exits.
cgroup.kill and reaches every descendant. Without one, axed kills the process group and every descendant it can find through /proc. If the process you started has already exited, axed kills only what is left in its process group.
When the process you started exits on its own, anything it left running in its group or cgroup keeps running while axed keeps its record. With a cgroup, axed kills those leftovers when it forgets the record. Without one, they keep running after axed forgets the record, because once the leader has exited axed cannot safely tell its group from an unrelated one. If leftovers matter, run with cgroups or stop the process before it exits. axed does not keep processes started with Exec without a request_id or through the Agent Sandbox API, so it kills their leftovers when they exit. Without a cgroup, it kills what is left in the group the moment the leader is reaped, while the group can still be told apart, so output the leftovers write afterwards is lost. With a cgroup, it kills them once their output has drained.
Wait for an exit
Processes.Wait returns the Process once it has exited and its output is complete. axectl wait prints why the process ended and exits with its exit code.
Exit message says how the process ended:
When axed kills a tree, the first cause it acted on wins: a process that times out and is then removed reports
TIMED_OUT. If the process had already exited on its own when axed acted, it keeps EXITED or SIGNALED.
Read resource usage
Process.usage reports CPU time and memory. For a running process, Get and List read it when they describe the process, so it is current; axed never samples in the background. Once the process exits, it holds the totals.
With a cgroup the figures cover the whole tree (
cpu.stat, memory.current, memory.peak, pids.current). Without one they cover only the process you started, from /proc, and scope says USAGE_SCOPE_LEADER: children it forked are not counted. axectl ps shows CPU seconds and memory in its CPU and MEM columns, with a * after leader-only figures.
Set a timeout
Limits.timeout (axectl --timeout) kills the tree after the process has run for that long. Time the sandbox spends suspended does not count, so a sandbox restored after an hour in a snapshot does not wake up and kill its jobs. Snapshots explains how axed measures running time.
- axectl
- gRPC
--timeout takes durations such as 500ms, 30s or 1m30s.The Agent Sandbox equivalent is
time_limit on ExecuteWithLimits, bounded by axed’s --execute-default-time-limit and --execute-max-time-limit. It uses the same running-time clock.Limit resources
Spec.limits takes four resource limits. Each must be positive; 0 fails with INVALID_ARGUMENT. How axed enforces them depends on whether it has a cgroup.
The operator can set daemon-wide defaults for requests that leave a limit unset, and ceilings no request may exceed:
--default-timeout, --default-memory, --default-max-tasks, --max-timeout and --max-memory. A request over a ceiling fails with INVALID_ARGUMENT (LIMIT_EXCEEDED). See Default policies.
Shutdown
When axed shuts down (SIGINT, or SIGTERM with the default--on-sigterm=shutdown), it stops accepting starts, sends SIGTERM to every running process group, waits up to two seconds (or --shutdown-timeout if shorter), and then kills what is left.
