s6 and runit: The Minimalist Approach

Updated

October 30, 2026

s6 and runit: The Minimalist Approach

In the lineage of Daniel J. Bernstein’s daemontools, runit and s6 represent the pinnacle of process supervision based strictly on the UNIX philosophy: write small programs that do one thing well, and compose them together.

+-----------------------------------------------------------+
|               The Process Supervision Hierarchy           |
|                                                           |
|       PID 1 (s6-svscan or runit)                          |
|             |                                             |
|             +---> supervisor (s6-supervise) -> daemon A   |
|             +---> supervisor (s6-supervise) -> daemon B   |
|             +---> logger     (s6-log)       <- stdout/err |
+-----------------------------------------------------------+

The Supervision Tree Model

In traditional init systems, daemons fork into the background and detach from their parent. If the daemon crashes, the init system does not know about it.

In supervision systems: - Daemons are forbidden to fork or background themselves (-D or foreground mode). - A dedicated lightweight supervisor process (s6-supervise or runsv) runs as the direct parent of the daemon. - The supervisor monitors the daemon via waitpid(). If the daemon crashes, the supervisor restarts it instantly in milliseconds. - Standard output and error streams are piped directly into a dedicated logging daemon (s6-log or svlogd) running with unprivileged credentials, preventing disk exhaustion via automatic rotation.

runit: Pure Simplicity (Void Linux)

runit operates via a three-stage directory lifecycle: - Stage 1 (/etc/runit/1): One-time system initialization (mounts, hostname, clock). - Stage 2 (/etc/runit/2): Launches the service directory (/var/service). - Stage 3 (/etc/runit/3): Clean system shutdown, unmounting storage and halting.

A service is simply a directory containing an executable run script:

#!/bin/sh
# /etc/sv/sshd/run
exec /usr/sbin/sshd -D

Enabling a service is accomplished by creating a symbolic link:

# ln -s /etc/sv/sshd /var/service/

The runsvdir daemon notices the new symlink within 5 seconds and launches the supervisor automatically.

s6: High-Assurance Supervision

Developed by Laurent Bercot (Skaaware), s6 is an industrial-strength supervision suite designed to eliminate race conditions completely: - Provides transactional notifications using FIFOs and readiness events (s6-notifyoncheck). - Fully supports cgroup management and notification protocols without requiring a monolithic binary. - Exceptionally tiny footprint: entire supervision stack fits in under 200 KB of RAM.