xtc_supervisor(3)
---xtc_supervisor(3)
OTP-style supervisor trees
| XTC_SUPERVISOR(3) | Library Functions Manual | XTC_SUPERVISOR(3) |
NAME
xtc_sup_start,
xtc_sup_add_child,
xtc_sup_stop, xtc_sup_join,
xtc_sup_alive,
xtc_sup_n_children,
xtc_sup_n_restarts —
OTP-style supervisor trees
SYNOPSIS
#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);
DESCRIPTION
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.
Strategies control which children get restarted on a child crash:
XTC_SUP_ONE_FOR_ONE- Only the crashed child restarts.
XTC_SUP_ONE_FOR_ALL- All children restart.
XTC_SUP_REST_FOR_ONE- The crashed child and all started after it (right siblings) restart, in order.
XTC_SUP_SIMPLE_ONE_FOR_ONE- Children spawned dynamically; not all known up front.
Restart policies per child:
XTC_RESTART_PERMANENT- Always restart on exit (normal or crash).
XTC_RESTART_TRANSIENT- Restart on abnormal exit only.
XTC_RESTART_TEMPORARY- 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.
xtc_sup_start()
spawns the supervisor and its initial children. Returns
XTC_OK with *out_sup set, or
XTC_E_INVAL on bad args (notably
n_children
<= 0);
empty supervisors not supported, see
examples/06_sqlxtc/main.c for a one-listener-child
workaround .
xtc_sup_add_child()
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
simple_one_for_one
supervisor, whose children are spawned on demand rather than all listed up
front.
xtc_sup_stop()
asynchronously requests shutdown. Children get ‘EXIT’ signals;
the supervisor exits when all are done.
xtc_sup_join()
waits up to timeout_ns for the supervisor to exit.
SEE ALSO
HISTORY
Appeared in xtc 0.1.
| May 28, 2026 | Debian |