LESSON 1.13 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW
Pipes and file descriptors
Watch a shell connect two programs with a pipe and a few small numbers.
Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 1.13 · PIPE BAY1 PROCESS · FDS 0, 1, 2 → TERMINAL
01
Stage 1 of 6 · FD table
Each process has a file-descriptor table. Its fds 0, 1 and 2 point to the terminal.
Explain it simply
This box is the shell, the program that runs your command. Its table maps small numbers, called file descriptors or fds, to open files. Every program reads fd 0, writes fd 1 and sends errors to fd 2. Here all three lead to the terminal, as the lsof tool would list them.
The shell, pid 6735, has fds 0, 1 and 2. All three point to the terminal /dev/pts/0.
process and its fd tablefd and referenceopen file and bytesoutput and resultstderr and waiting
Toy: 3 processes · one CPU · a 32-byte pipe (Linux: 64 KiB) · pids and inodes are stand-ins
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
An fd is an index into the table of one process.
PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
- 5 more stages and 2 live controls
- 2 mix-up cards and 3 predict-then-reveal checks
- Watch it as a narrated video, in three voices
- Every Pro lesson and capstone · 656 in total
$99 a year, or $15 a month. Cancel any time.