Project 9: Job Control System

Full job control with jobs, fg, bg, %N job references, process groups, and terminal control—everything needed to manage multiple concurrent jobs.

Quick Reference

Attribute Value
Primary Language C
Alternative Languages Rust, Zig
Difficulty Level 4: Expert (The Systems Architect)
Time Estimate 2 weeks
Knowledge Area Operating Systems / Process Groups
Tooling Unix Shell
Prerequisites Projects 1-8, deep understanding of signals and process groups

What You Will Build

Full job control with jobs, fg, bg, %N job references, process groups, and terminal control—everything needed to manage multiple concurrent jobs.

Why It Matters

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

Core Challenges

  • Process groups (setpgid to create groups, all pipeline members in same group) → maps to process organization
  • Terminal foreground group (tcsetpgrp to give terminal control) → maps to terminal management
  • Job table (tracking all jobs, their states, their process groups) → maps to state management
  • Continuing stopped jobs (SIGCONT to resume, fg vs bg) → maps to job manipulation
  • Job notifications (detecting and reporting state changes) → maps to async updates

Key Concepts

  • Job control concepts: “The GNU C Library Manual” Chapter 28 - GNU
  • Process groups: “Advanced Programming in the UNIX Environment” Chapter 9 - Stevens
  • Terminal control: “The Linux Programming Interface” Chapter 34 - Kerrisk
  • Practical job control: “How does job control work?” by emersion (blog)

Real-World Outcome

$ ./mysh
mysh> sleep 100 &
[1] 12345
mysh> sleep 200 &
[2] 12346
mysh> jobs
[1]- Running    sleep 100 &
[2]+ Running    sleep 200 &
mysh> fg %1
sleep 100
^Z
[1]+ Stopped    sleep 100
mysh> bg %1
[1]+ sleep 100 &
mysh> kill %2
[2]  Terminated sleep 200
mysh> fg
sleep 100
^C
mysh>

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: SHELL_INTERNALS_DEEP_DIVE_PROJECTS.md
  • “Advanced Programming in the UNIX Environment” by W. Richard Stevens