Luke Oliff.

TIL: Creating Named Pipes With mkfifo for IPC

·TIL·1 min read·Luke Oliff

Named pipes are files that act as buffers between processes. One process writes, another reads, no network, no temp file.

mkfifo mypipe

In one terminal:

cat > mypipe

In another terminal:

cat < mypipe

Whatever you type in the first terminal appears in the second. The pipe blocks when the buffer is full and drains when the reader catches up.

# Writer: stream audio data into the pipe
ffmpeg -i input.wav -f s16le -acodec pcm_s16le mypipe

# Reader: process the audio from the pipe
python process_audio.py < mypipe

I used named pipes for experiments with streaming audio data between processes before building proper WebSocket pipelines. It is a simple way to test one direction at a time.

Do named pipes persist after use?

They persist as files until you rm them. Clean up with rm mypipe.