LearnViz CompSci
Home / Learn / Operating Systems / Pipes and Signals

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

  1. A producer writes bytes into the pipe.
  2. The kernel buffers them.
  3. The consumer reads them in order.
  4. A signal such as SIGINT can interrupt a process asynchronously.
  5. 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

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. 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?
Byte streams between processes and asynchronous notifications. It belongs to Operating Systems and is a beginner-level topic.
Where do people use Pipes and Signals?
Shell pipelines, log processing, graceful shutdown of servers on SIGTERM, reloading configuration with SIGHUP and detecting broken pipes use these mechanisms.
What is the most common mistake with Pipes and Signals?
Signal handlers can interrupt code at any point, so only async-signal-safe functions may be called inside them.
What should I learn before this topic?
Start with Inter-Process Communication, the topic just before it in Operating Systems.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Operating Systems quiz.
Is Pipes and Signals hard to learn?
It is a Beginner topic, so it works as an entry point. If the terms are new, read the explanation twice and try the visualizer before the quiz.
How long does it take to learn Pipes and Signals?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Pipes and Signals?
Inter-Process Communication, Race Conditions, Fork and Exec are closely connected. The full list is in the related topics section of this page.
What should I study after Pipes and Signals?
Continue with Race Conditions, the next topic in Operating Systems.

Related topics