IPC and Pipes
Inter-Process Communication (IPC) is the set of OS-provided mechanisms, such as pipes, named pipes, message queues and shared memory, that let isolated processes exchange data despite having separate memory. A pipe is one of the simplest IPC mechanisms: a one-way byte stream connecting one process's output directly to another process's input, as when chaining shell commands.
Processes are deliberately isolated from each other, one process can't just reach into another's memory. When two processes genuinely need to share data or coordinate, they need the OS to provide a controlled channel for that. That whole category of mechanisms is called Inter-Process Communication, or IPC.
The main IPC mechanisms
- Pipes: a one-way byte stream connecting one process's output directly to another process's input, most commonly seen chaining commands together in a shell.
- Named pipes (FIFOs): like a pipe, but it exists as an actual named entry, so unrelated processes (not just a parent and its child) can open and use it, as long as they both know its name.
- Message queues: the OS maintains a queue of discrete messages that one process can push onto and another can pop off, without either process needing to be running at the exact same instant.
- Shared memory: the OS maps the same physical memory region into more than one process's address space, letting them read and write it directly with no data copying between them, the fastest IPC mechanism, but it requires the processes to coordinate access themselves (usually with semaphores) to avoid corrupting shared data.
- Sockets: a general-purpose, network-capable communication endpoint, usable for IPC between processes on the same machine or across a real network to a different machine entirely.
How a pipe actually works
A pipe is a unidirectional, in-kernel buffer, one process writes bytes into one end, and another process reads bytes out the other end, in the same order they were written, like a real physical pipe with data flowing one way through it. The OS itself manages the buffer and automatically blocks a process trying to read from an empty pipe (until data arrives) or write to a full one (until space frees up), so the two processes don't need to build that coordination themselves.
A concrete example
The Unix/Linux shell command ls | grep "report" | wc -l chains three separate processes together with two pipes: ls lists files and writes that output into the first pipe; grep reads from that pipe, filters for lines containing "report", and writes the matching lines into a second pipe; wc -l reads from that second pipe and counts the lines, printing a final count. Each of these three programs has no idea it's part of a chain, ls just writes to what it thinks is its normal output, and the shell is what actually wires each pipe's write-end to the next command's read-end. This is IPC via pipes doing real, visible work every time anyone chains shell commands with the | operator.
Where this matters in real systems
Every Unix-like shell (bash, zsh) relies on pipes as a foundational feature, chaining small, single-purpose command-line tools together is a core part of the whole Unix philosophy, and it only works because pipes give processes an easy, OS-managed way to hand a stream of data from one to the next. Beyond shells, real applications use these same mechanisms directly: a web browser's separate rendering and network processes communicate through IPC channels (often built on sockets or shared memory) precisely so a crash in one process doesn't automatically corrupt or crash the other.
What interviewers actually ask about IPC and pipes
- "What is IPC, and why is it needed?" The set of OS-provided mechanisms letting isolated processes exchange data or coordinate, needed because processes have separate memory by design and can't directly access each other's data.
- "What is a pipe, specifically?" A unidirectional, in-kernel byte stream connecting one process's output to another process's input, with the OS automatically handling blocking when the pipe is empty or full.
- "What's the difference between a pipe and a named pipe (FIFO)?" A plain pipe typically only connects related processes (like a parent and child); a named pipe exists as an actual named filesystem entry, so any two processes that know its name can use it, related or not.
- "Why is shared memory the fastest IPC mechanism, and what's the tradeoff?" Because processes read/write the same physical memory directly with zero data copying; the tradeoff is that the processes themselves must coordinate access (usually via semaphores) to avoid corrupting shared data, since the OS doesn't manage that coordination automatically the way it does with pipes.
Key takeaways
- IPC is the set of OS mechanisms letting isolated processes exchange data or coordinate.
- Pipes are simple, unidirectional, in-kernel byte streams connecting one process's output to another's input.
- Named pipes extend this to unrelated processes via a shared name; shared memory is fastest but requires manual coordination; sockets work across a real network too.
- Shell command chaining with
|is real, everyday IPC via pipes in action.
More in Process Management
Browse all Operating Systems topics
Log in to save which topics you've read across every subject.
Frequently asked questions
What is IPC, and why is it needed?
The set of OS-provided mechanisms letting isolated processes exchange data or coordinate, needed because processes have separate memory by design and can't directly access each other's data.
What is a pipe, specifically?
A unidirectional, in-kernel byte stream connecting one process's output to another process's input, with the OS automatically handling blocking when the pipe is empty or full.
What's the difference between a pipe and a named pipe (FIFO)?
A plain pipe typically only connects related processes (like a parent and child); a named pipe exists as an actual named filesystem entry, so any two processes that know its name can use it, related or not.
Why is shared memory the fastest IPC mechanism, and what's the tradeoff?
Because processes read/write the same physical memory directly with zero data copying; the tradeoff is that the processes themselves must coordinate access (usually via semaphores) to avoid corrupting shared data, since the OS doesn't manage that coordination automatically the way it does with pipes.