What exactly is the difference between pipes and streams

pipe

I read about pipes and streams and I’m still confused on how it’s implemented.

A program is started and it reads data from “standard input” stream (stdin), which is where the keyboard sends data to.

My question is, how is that different from a pipe? Piping allows me to have a process that sends data to a pipe, and another process is reading data from it.

When the keyboard is pressed, data is sent to stdin and a program is reading data from this same stream.

A "read" operation is executed as soon as data is sent to this stream, just like a pipe.

Are these streams piped?

Best Answer

Unix terminal i/o has traditionally been implemented as some sort of queue. Older kernels used clists. V8 Unix used streams. In most cases, clists and streams are used to implement a portion of the link between a user process (specifically, a file descriptor) and a character device driver (for example, a serial port or a pty).

Pipes are also a queue, but they link user processes (specifically, a pair of file descriptors). There are a variety of implementations of pipes, including sockets; a special type of file; and even STREAMS (STREAMS is a derivative of V8 streams.)

So, streams and pipes are both implementations of a queue, but they are used in different situations.