Workspace

Operating systems

3 day streakD
Systems syllabus
PHASE 01 · MODULE 02

Operating systems.

Every agent harness is a process supervisor. Most flaky shell tools come from misunderstanding pipes, process groups and terminals.

A process is a private address space plus a table of file descriptors. The kernel is the only way to touch anything outside it, and each crossing is a system call. Once you can see the system calls, most mysterious behaviour stops being mysterious.

7 lessons108 minutes of reading6 illustrations
Start lesson 1
Basics
  • Processes and threads
  • fork and exec
  • System calls
  • File descriptors
  • Pipes
  • Signals
  • Exit codes
  • Environment variables
Depth
  • Virtual memory and page faults
  • mmap and the page cache
  • Copy-on-write
  • Scheduling
  • PTYs
  • Sessions and process groups
  • Zombies and orphans
  • PID 1 in containers
  • The OOM killer
Current
  • EEVDF scheduler (Linux 6.6+)
  • sched_ext (Linux 6.12+)
  • pidfd against PID reuse
  • Landlock for unprivileged sandboxing

Lessons

  1. 01Processes and system callsA process is an address space, a set of open files and a thread or more of execution. The kernel boundary is where every outside effect happens.Basics14 min
  2. 02fork, exec, exit codes and environmentUnix creates a process in two steps: copy yourself, then replace the copy with a new program. Learn the steps, and what the exit status really carries.Basics13 min
  3. 03Pipes, buffers and EOFA pipe is a small kernel buffer with a reader and a writer. When nobody reads, the writer blocks. When anybody still holds the write end, the reader never sees EOF.Basics15 min
  4. 04Signals, process groups and orphansKilling a command means killing its whole tree. Learn process groups and sessions, why zombies appear, and what changes when your harness is PID 1.Depth17 min
  5. 05Terminals, PTYs and isattyPrograms behave differently when they think a person is watching. Learn what a pseudo-terminal is, and why git log hangs in one harness and not another.Depth13 min
  6. 06Virtual memory, page faults and the OOM killerEvery process sees its own clean address space. Behind it, the kernel maps pages lazily, shares them when it can, and kills someone when it runs out.Depth16 min
  7. 07Build a run_command tool that cannot hangPut the module together into the tool every coding agent needs, then see what Linux added in recent years to make it safer: pidfd, Landlock, EEVDF and sched_ext.Current20 min

Module lab

  1. Write a small shell that supports pipes.
  2. Write a run_command tool with streamed stdout and stderr, a timeout, whole-tree kill, an output cap and an optional PTY.
  3. Use strace -f to watch what it really does.

Interview questions

Your agent's shell tool hangs sometimes. Walk me through the causes.

Full pipe, stdin or pager wait, a grandchild holding stdout, and a timeout that signals only the child.

Why does the same command print differently under a harness?

Programs call isatty and change colour, paging and buffering when stdout is a pipe.

What goes wrong when your app runs as PID 1 in a container?

Signal defaults differ, so SIGTERM may be ignored, and zombies are not reaped.

Read

  • Operating Systems: Three Easy Pieces (free online)
  • The Linux Programming Interface, Michael Kerrisk
  • Man pages: pipe(7), pty(7), signal(7) and credentials(7)

A good place to start

Explore a pattern

A little guidance

Start with a pattern, read through a problem, and mark it solved when the idea clicks. Save anything you want to revisit.

New tutorials are added one at a time. Your bookmarks and solved checkmarks stay in this browser.

Explore the roadmap