When is it a good situation to use an ordinary pipe and when is it a good situation to use a named pipe?
Printable View
When is it a good situation to use an ordinary pipe and when is it a good situation to use a named pipe?
Named pipes are available to "any" application to connect to at "any time".
Regular pipes are only available when the application that creates the pipe also creates the child process.
--
Mats
Check this site out
Named pipes are usually used to "trick" some program into reading from a pipe, when it is normally set up to read from a file in the filesystem. If some program, call it A, wants to read from a file, but you want to instead pipe some input into it, then you can create a named pipe and tell program A to read from that.
There are certain limitations. For instance, pipes are not seekable, so if process A attempts to seek, it will fail if you pass a pipe to it. And if process A attempts to stat() its input, because for instance it wants to determine file size, it will not receive meaningful data. It goes on and on -- if process A attempts to close and then reopen the pipe (not an unusual state of affairs for a program which expects its input to come from a "real" file) then things will not behave normally.
Normally, pipes, are created with the pipe() function, and are intimately related between parent and child process. Named pipes are only used in very special circumstances.
What would be a simple real world scenario(s) in which I would want to use each of the types
Any suggestions?
There really is no punchline?