Beginner Topic 17 of 51 Operating Systems
Pipes and Signals
Byte streams between processes and asynchronous notifications.
How it works
A pipe is a unidirectional byte stream with a read end and a write end, connecting the output of one process to the input of another, as in cat file | sort. Writers block when the buffer is full and readers block when empty. Signals are asynchronous notifications sent to a process, such as SIGINT from Ctrl+C, SIGTERM to ask for termination, SIGKILL which cannot be caught and SIGCHLD when a child exits. Handlers run when a signal is delivered.
Step-by-step walkthrough
- A producer writes bytes into the pipe.
- The kernel buffers them.
- The consumer reads them in order.
- A signal such as SIGINT can interrupt a process asynchronously.
- The target runs a signal handler or the default action.
Where it is used
Shell pipelines, log processing, graceful shutdown of servers on SIGTERM, reloading configuration with SIGHUP and detecting broken pipes use these mechanisms.
Common pitfall
Signal handlers can interrupt code at any point, so only async-signal-safe functions may be called inside them. Forgetting to close unused pipe ends prevents end-of-file. Writing to a closed pipe raises SIGPIPE. Signals can coalesce or be lost, so do not rely on them for counting events.
Where it fits in the course
Pipes and Signals is topic 17 of 51 in Operating Systems, rated Beginner. It follows Inter-Process Communication. The next topic is Race Conditions.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Operating Systems quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Operating Systems quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Pipes and Signals?
Where do people use Pipes and Signals?
What is the most common mistake with Pipes and Signals?
What should I learn before this topic?
How can I practice it?
Is Pipes and Signals hard to learn?
How long does it take to learn Pipes and Signals?
Which topics are related to Pipes and Signals?
What should I study after Pipes and Signals?
Related topics
- Inter-Process Communication (Operating Systems)
- Race Conditions (Operating Systems)
- Fork and Exec (Operating Systems)
- Critical Section (Operating Systems)
- Pipes and Redirection (DevOps & Tooling)
- Analog vs Digital Signals (Mobile, Embedded & IoT)