Home » Software » Basic Guide of Interprocess Communication and Pipes

Basic Guide of Interprocess Communication and Pipes

Interprocess Communication (IPC) is a method of communication by exchanging data / information among multiple threads or multiple process. The usefulness of creating a child process from parent process is limited if they don’t have ability to communicate between the process. Interprocess communication (IPC) enables the exchange of information / data that are running on same platform or same CPU. The oldest form and most commonly used of IPC is called a pipe.

IPC Basic Guide of Interprocess Communication and Pipes

Mainly, communication using pipe consists of two file descriptors (one for reading and one for writing). There are two kinds of pipes :

  • Half Duplex, a pipe which can send data/information in one direction.
  • Full Duplex, a pipe which can send and receiving data/information at the same time.

You can create pipes by using Pipe function, which returns two files (a read file and a write file) descriptor in an integer array format. In C and C++ Programming Language, Interprocess Communications (IPC) Functions can be obtained from unistd.h

List-of-IPC-functions-unistd.h Basic Guide of Interprocess Communication and Pipes

List of Some Interprocess Communication Functions from unistd.h

Interprocess Communication Example in C

In this example we will show you a complete program that creates a pipe to communicating between parent and child process.

Parent Process Example

Parent process will create a new process (child) and communicate using a pipe

Child Process Example

Child Process will be a program that launched from parent

Now it’s done. Try to compile them. If it can’t be compiled maybe you can check for common errors.

One thought on “Basic Guide of Interprocess Communication and Pipes

  1. Sabina Carlisle says:

    magnificent submit, very informative. I’m wondering why the other specialists of this sector do not understand this.
    You should continue your writing. I’m sure, you’ve a huge readers’ base already!

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *

This site uses Akismet to reduce spam. Learn how your comment data is processed.