Project 2: Custom Process Supervisor (Mini systemd)

A simplified init system that reads unit files, manages process lifecycles, handles dependencies, restarts failed services, and logs to stdout with timestamps.

Quick Reference

Attribute Value
Primary Language C
Alternative Languages Rust, Go
Difficulty Level 4: Expert
Time Estimate 2-4 weeks
Knowledge Area Process Management / Systems Programming
Tooling Init System Logic
Prerequisites C or Rust, understanding of fork/exec/wait, signal handling basics

What You Will Build

A simplified init system that reads unit files, manages process lifecycles, handles dependencies, restarts failed services, and logs to stdout with timestamps.

Why It Matters

This project builds core skills that appear repeatedly in real-world systems and tooling.

Core Challenges

  • Parsing INI-style unit files with sections like `[Unit]`, `[Service]`, `[Install]` (maps to configuration)
  • Building a dependency graph and starting services in correct order (maps to ordering)
  • Forking processes, handling SIGCHLD, reaping zombies (maps to process management)
  • Implementing restart policies (always, on-failure, on-success) (maps to service lifecycle)
  • Tracking service state transitions (maps to state machine)

Key Concepts

  • Process creation: “The Linux Programming Interface” Ch. 24-26 by Michael Kerrisk
  • Signal handling: “Advanced Programming in the UNIX Environment” Ch. 10 by Stevens & Rago
  • Dependency graphs: “Grokking Algorithms” Ch. 6 (Topological Sort) by Aditya Bhargava
  • State machines: “Dive Into Systems” Ch. 13 by Matthews, Newhall, Webb

Real-World Outcome

Deliver a working demo with observable output that proves the feature is correct.


Implementation Guide

  1. Reproduce the simplest happy-path scenario.
  2. Build the smallest working version of the core feature.
  3. Add input validation and error handling.
  4. Add instrumentation/logging to confirm behavior.
  5. Refactor into clean modules with tests.

Milestones

  • Milestone 1: Minimal working program that runs end-to-end.
  • Milestone 2: Correct outputs for typical inputs.
  • Milestone 3: Robust handling of edge cases.
  • Milestone 4: Clean structure and documented usage.

Validation Checklist

  • Output matches the real-world outcome example
  • Handles invalid inputs safely
  • Provides clear errors and exit codes
  • Repeatable results across runs

References

  • Main guide: SYSTEMD_LEARNING_PROJECTS.md
  • “Advanced Programming in the UNIX Environment” by Stevens & Rago