xtc_supervisor(3)

---

xtc_supervisor(3)

OTP-style supervisor trees

XTC_SUPERVISOR(3) Library Functions Manual XTC_SUPERVISOR(3)

xtc_sup_start, xtc_sup_add_child, xtc_sup_stop, xtc_sup_join, xtc_sup_alive, xtc_sup_n_children, xtc_sup_n_restartsOTP-style supervisor trees

#include <xtc.h>
#include <xtc_orc.h>

int
xtc_sup_start(xtc_loop_t *loop, const xtc_sup_opts_t *opts, const xtc_child_spec_t *children, int n_children, xtc_supervisor_t **out_sup);

int
xtc_sup_add_child(xtc_supervisor_t *sup, const xtc_child_spec_t *spec, xtc_pid_t *out_pid);

int
xtc_sup_stop(xtc_supervisor_t *sup);

int
xtc_sup_join(xtc_supervisor_t *sup, int64_t timeout_ns);

int
xtc_sup_alive(const xtc_supervisor_t *sup);

int
xtc_sup_n_children(const xtc_supervisor_t *sup);

int
xtc_sup_n_restarts(const xtc_supervisor_t *sup);

xtc_supervisor is an OTP-style supervisor: it owns a set of child specs, spawns them, observes failures, and restarts them per the configured strategy. Failures isolate to children; the supervisor's own liveness is independent of any single child.

control which children get restarted on a child crash:

Only the crashed child restarts.
All children restart.
The crashed child and all started after it (right siblings) restart, in order.
Children spawned dynamically; not all known up front.

Restart policies per child:

Always restart on exit (normal or crash).
Restart on abnormal exit only.
Never restart; one-shot.

Restart intensity: opts.max_restarts restarts within opts.period_ns exhausts the supervisor; it gives up and exits. Default: 1 in 5 seconds.

() spawns the supervisor and its initial children. Returns XTC_OK with *out_sup set, or XTC_E_INVAL on bad args (notably n_children ); empty supervisors not supported, see examples/06_sqlxtc/main.c for a one-listener-child workaround .

() adds one child to a running supervisor from a xtc_child_spec_t, returning the new child's pid in *out_pid. This is the dynamic path used with a supervisor, whose children are spawned on demand rather than all listed up front.

() asynchronously requests shutdown. Children get ‘EXIT’ signals; the supervisor exits when all are done. () waits up to timeout_ns for the supervisor to exit.

xtc_app(3), xtc_proc(3), xtc_svr(3), xtc(7)

Appeared in xtc 0.1.

May 28, 2026 Debian

View the mdoc source