Linux System Programming · advanced · ~20 min

Mini shell project

Combine fork/exec/wait to build a tiny REPL shell.

Lesson

A shell loop is: read a line, parse into argv, fork+exec, wait. About 60 lines for a usable subset (no pipes/redirections).

Implementing this is the rite of passage for Linux systems programming. It cements fork's parent/child split, exec's image replacement, and the wait/exit contract.

Common mistakes

  • Forgetting to handle EOF (Ctrl-D) on stdin — your shell needs to exit cleanly.
  • Not tokenising properly: argv must be NULL-terminated.