Reputation: 2593
I recently stumbled across something called pipe (all small letters) and fork (also all small letters). Apparently pipe "is a method of connecting the standard output of one process to the standard input of another". What I do not understand is what does standard input output of a process mean here. I already know that functions can call other functions and use the values returned by them so what is special about pipe, why do we need pipes? I have never come across these in my C/C++ books, what mystery is this? A simple way to communicate between two applications (I am not using the word process here) is that one application creates a file, calls another application and let it open this file and process its data and create a new result file and than terminate itself. Than the original application can continue processing and read from the result file and delete the file it created first. This is a simple way for two applications to communicate, I think that in the age of .Net framworks and complex operating systems, this must be even easier right?
Also, what is a fork? is it something specific to C++? I remember reading somewhere on internet that by using fork we can open another application from out C++ application. However, I do not know of the limitations and implications of this approach and any drawbacks that it may have. Why do we need fork? What does it do?
I do not wish that anyone has to write several pages of information. I just wish to understand what these things are, what do they do, why do we need them, and how come my C/C++ book did not cover these two?
Upvotes: 0
Views: 526
Reputation: 693
These are unix system calls. They are not part of the C++ language or standard libraries, but are specific to unix-like operating systems.
fork creates a new process, and pipe creates a one-way communication channel. pipe and fork are often combined and used for inter-process communication.
Upvotes: 1