Reputation: 38
I need to learn how to create a pipe
and use fork
, and also how to write to a pipe
and read
, in VC++ 2010.
Are there any tutorials on how to do that?
Upvotes: 1
Views: 6605
Reputation: 898
This question is already answered in detail here. Quoting verbatim from the same answer
A pipe is a mechanism for interprocess communication. Data written to the pipe by one process can be read by another process. The primitive for creating a pipe is the pipe function. This creates both the reading and writing ends of the pipe. It is not very useful for a single process to use a pipe to talk to itself. In typical use, a process creates a pipe just before it forks one or more child processes. The pipe is then used for communication either between the parent or child processes, or between two sibling processes. A familiar example of this kind of communication can be seen in all operating system shells. When you type a command at the shell, it will spawn the executable represented by that command with a call to fork. A pipe is opened to the new child process and its output is read and printed by the shell. This page has a full example of the fork and pipe functions...
Upvotes: 2