we can use pipe between two related process only, related means both process has same pid in their past. after that we can read and write the data from any end.
To make a related process between two unrelated process, we have to do fork.
Now question is why we are using fork to make related process.
We are using fork to create a child process for our current process.
In this case child has its own pid but its ppid is same as current process pid.
It means both has a relation, but now problem is how we relate two different process.
we can create a relation between two different process with the help of execl().
We are using execl() in child only. besause if we are using execl() in parent thn it is not execute the whole process, it is terminated after the execl(). So it is compulsary to use execl() in child .
pipe has two descriptor one and zero.
zero for read abd One for write.
if pipe return zero it means it is created else it is not created.we have to pass the file descriptor to the other process through execl () in child.
Execl() takes string only and it is terminated by null.
and to make a string to pipe file descriptor, we are using sprintf function.
To take all the arrguments from child to other process we have to make the command line function to that funcion.
Now we can use pipe between two different process.