How sweets/hummingbird works
Project type and purpose
• This is a minimal, lightning-fast Linux init system written in C. It replaces traditional init systems (like sysvinit, runit, or systemd) by providing only the essential “start” and “stop” functionality via three sequential runlevels: fs, interlude, and tty.
File structure
• Top-level binaries (bin/): reboot and shutdown wrappers.
• dist/: distribution-specific runlevel scripts and libraries under kiss/ and trajan/.
• src/: core C source files (hummingbird.c, init.c, shutdown.c, signal.c) and headers.
• usr/lib/hummingbird/: installed runtime libraries and scripts for each runlevel.
• Makefile, Travis CI config, LICENSE, README: build, test, and metadata.
README for additional insights
• Describes three runlevels:
• fs: after mounting pseudo-filesystems
• interlude: before spawning ttys
• tty: launching terminal sessions
• Installation replaces /usr/lib/hummingbird with dist/<distro> snapshots.
a. Main components
• Bootloader & Kernel
• Init binary (hummingbird)
• Runlevel directories: fs, interlude, tty, each containing scripts and rc.lib
• Signal handler and shutdown logic
• Wrapper binaries (reboot, shutdown)
• Distribution-specific overlays (dist/)
b. Relationships and interactions
1. Bootloader → Kernel: hand-off to PID 1
2. Kernel → /sbin/init (hummingbird): invoked as PID 1
3. Init core reads configuration or default /usr/lib/hummingbird/*
4. Init forks/execs all scripts in fs/, waits for completion
5. Init forks/execs all scripts in interlude/, waits
6. Init forks/execs all scripts in tty/, launches getty processes
7. Signal handling: on SIGTERM or wrapper binaries, invoke shutdown sequence in reverse order or call shutdown.c
8. Shutdown: kill children, unmount, power-off
c. Architectural patterns / design principles
• Linear runlevels (simple pipeline)
• Modular script directories for distribution overrides
• Single-threaded core with fork/exec model (POSIX compliance)
• Minimal dependencies (C stdlib only)
d. Relevant technologies
• C99 codebase (gcc, clang, TCC compatible)
• POSIX fork/exec, signal APIs
• /sbin/init replacement
Detailed breakdown for the engineer
• Layer 1: Bootloader & Kernel (annotate where /sbin/init is invoked)
• Layer 2: Init core
• hummingbird.c: main loop
• init.c: argument parsing, path resolution
• signal.c: catch SIGTERM & SIGINT
• shutdown.c: teardown logic
• Layer 3: Runlevels (modular script execution)
• fs/ → mount-dependent services
• interlude/ → pre-TTY tasks
• tty/ → getty spawn
• rc.lib → shared helper functions
• Layer 4: Wrappers & distribution overlays
• bin/reboot & bin/shutdown call hummingbird’s shutdown path
• dist/<distro> replaces /usr/lib/hummingbird at install time