Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between pipes in Windows and Linux?

What are the differences between pipes in Windows and Linux?

like image 860
Brian R. Bondy Avatar asked Oct 10 '08 16:10

Brian R. Bondy


People also ask

What are pipes in Windows?

A pipe is a section of shared memory that processes use for communication. The process that creates a pipe is the pipe server. A process that connects to a pipe is a pipe client. One process writes information to the pipe, then the other process reads the information from the pipe.

What is a pipe in Linux?

In Linux, the pipe command lets you sends the output of one command to another. Piping, as the term suggests, can redirect the standard output, input, or error of one process to another for further processing.

What is difference between pipes and named pipes?

A traditional pipe is “unnamed” and lasts only as long as the process. A named pipe, however, can last as long as the system is up, beyond the life of the process. It can be deleted if no longer used. Usually a named pipe appears as a file and generally processes attach to it for inter-process communication.

What are pipe files in Linux?

A FIFO, also known as a named pipe, is a special file similar to a pipe but with a name on the filesystem. Multiple processes can access this special file for reading and writing like any ordinary file. Thus, the name works only as a reference point for processes that need to use a name in the filesystem.


2 Answers

One difference that I know of, is that named pipes under Linux are actual entries in the filesystem (you'll see it in a directory listing, they have a special type), whereas on Windows they are stored in some magical repository somewhere (they are all accessed via the path "\\.\pipe\".

Secondly, in Linux you can just write/read from pipes as if they were any other file, using standard file IO methods. Whereas on windows, you have to use the special 'Pipe' functions which are part of the Win32 API.

I like linux's method better, because it lets me use pipes with any app I want. Eg:

mkfifo pipe.wav
decodeMP3 song.mp3 --out pipe.wav &
encodeAVI video.mpeg pipe.wav --out video.avi

This lets me pipe the output of the MP3 decoder directly into the video decoder, instead of having to first decode the entire MP3 into a WAV file on disk. It's handy if you have a dual-core CPU, because then you are running both operations at once, for a nice speedup.

like image 162
davr Avatar answered Sep 20 '22 17:09

davr


Another important difference

Under windows

A | B | C 

Until A is done with it's output B does not start reading, The same for B output being read by C

*nix hooks the input and output together so that C can read B's output and B can read A's output while A and B are still running

The throughput is about the same but output shows up faster with *nix.

like image 22
lkreinitz Avatar answered Sep 21 '22 17:09

lkreinitz