Inter-Process Communication
System Calls & Processes · Assembly & OS track
4 min read
In this module
Why Processes Need to Talk
Processes are walled off from each other on purpose. Each gets its own memory space, and one process can't peek at another's data. Great for stability and security. Awkward when processes genuinely need to coordinate. A browser might run each tab as a separate process and still need them to share session state. A shell needs to chain commands together with pipes.
So the OS hands out a toolkit of inter-process communication (IPC) mechanisms that let processes talk without tearing down the walls.
Pipes
A pipe is the simplest IPC mechanism going. It carves out a one-way channel between two processes: one writes, the other reads. Run ls | grep ".txt" in a terminal and the shell wires up a pipe connecting ls's output to grep's input.
Pipes are pure byte streams. They impose no structure on the data, which makes them easy to use. An ordinary pipe has no name, so only processes that inherit its file descriptors from a common ancestor (parent-child, usually) can use it. Named pipes, or FIFOs, lift that restriction by appearing as a file in the filesystem.
On Unix-like systems, pipes are accessed through file descriptors, the same interface used for files, sockets, and any other I/O. A pipe hands you two of them: one for reading, one for writing. That uniformity is a core Unix design principle.
Here's the plumbing a shell does for ls | grep, minus the exec() calls: create a pipe, fork, and have each side close the end it doesn't use. Run it, then delete the child's close(fds[1]) and predict what happens.
Without that close(), the child itself still holds a write end, so the kernel never reports end-of-file and the reader waits forever. The parent waits on the child, so the runner ends up killing both at its time limit, usually before any buffered output appears. A shell adds one more step: dup2() moves each pipe end onto the child's standard output or standard input before calling exec().
Shared Memory
When you need raw speed, the OS can map a region of physical memory into the address spaces of two or more processes. Both can then read and write this shared memory region directly, no syscall overhead per message.
The catch is synchronisation. When multiple processes hammer on the same memory, you need locks or other primitives to keep them from stepping on each other — race conditions, where the outcome depends on whose write landed first.
Message Queues
A message queue is a kernel-managed buffer where processes drop discrete messages and others pick them up. Unlike pipes, queues allow multiple senders and receivers, and messages can carry types or priorities. The kernel handles the buffering and delivery for you.
Sockets
A socket is the same interface programs use for network connections, pointed at the local machine instead. Unix domain sockets have a path in the filesystem (or an abstract name on Linux), carry either byte streams or discrete messages in both directions, and can even pass open file descriptors between processes. Unrelated processes can use them, which is why so much of a modern desktop talks this way: the X and Wayland display servers, D-Bus, Docker's control socket and most database clients on the same host.
Signals
A signal is a tiny nudge — a lightweight notification sent to a process. A standard signal carries no data, just the bare fact that "this event happened." (Real-time signals sent with sigqueue() can carry a single integer or pointer.) Common ones include SIGKILL (die now), SIGTERM (please die gracefully), and SIGINT (the user smashed Ctrl+C).
When a signal arrives, the process can handle it with a custom function, ignore it, or let the default action play out. SIGKILL and SIGSTOP are the exceptions: they can't be caught or ignored. Best suited for simple notifications, not bulk data.
Choosing the Right Mechanism
Each IPC method earns its keep somewhere different. Pipes shine for streaming data between related processes. Shared memory wins on raw throughput for big payloads. Message queues give you structured communication with types and priorities. Sockets are the general-purpose choice when unrelated processes need a two-way channel. Signals handle bare-bones event notification. Real systems mix and match these, picking whichever fits the job.