When is it a good situation to use an ordinary pipe and when is it a good situation to use a named pipe?
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
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
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.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
What would be a simple real world scenario(s) in which I would want to use each of the types
Last edited by NuNn; 03-11-2009 at 06:33 AM.
Any suggestions?
There really is no punchline?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge