← Parminces
Brian "Beej Jorgensen" Hall, 2010

Beej's Guide to
Unix IPC

The classic guide to interprocess communication on Unix, rebuilt as interactive lessons. From fork() to sockets, with live simulations at every step.

10
Chapters
30+
Simulations
50+
Quizzes
Part I: Process Fundamentals
Chapter 2

A fork() Primer

Creating child processes, zombie prevention, wait(), and the parent-child relationship.

Chapter 3

Signals

Catching and sending signals, sigaction(), signal handlers, and async-safe functions.

Part II: Byte Stream IPC
Chapter 4

Pipes

Anonymous pipes, pipe() + fork(), dup() for stdin/stdout redirection, implementing "ls | wc".

Chapter 5

FIFOs (Named Pipes)

Named pipes on disk, producer-consumer patterns, O_NDELAY, and multi-writer scenarios.

Part III: Synchronization
Chapter 6

File Locking

Advisory locks with fcntl(), read vs write locks, struct flock, and deadlock avoidance.

Chapter 8

Semaphores

System V semaphores, semget/semop/semctl, the "fatal flaw" race condition, and SEM_UNDO.

Part IV: Shared Data
Chapter 7

Message Queues

System V message queues, ftok() keys, typed messages, priority retrieval, kirk & spock.

Chapter 9

Shared Memory Segments

shmget/shmat/shmdt, direct pointer access, concurrency dangers, and the ipcs command.

Chapter 10

Memory Mapped Files

mmap() and munmap(), mapping files to pointers, page alignment, and MAP_SHARED vs MAP_PRIVATE.

Part V: Full-Duplex Communication
Chapter 11

Unix Sockets

Unix domain sockets, server/client architecture, socketpair(), and the echo server pattern.