How it works...
Define a macro max, of size 50 and two string variables, wstr and rstr, of size max. The wstr string will be used for writing into the pipe and rstr will be used for reading from the pipe. Define an array, pp, of size 2, which will be used for storing the file descriptors of the read and write ends of the pipe. Define a variable, p, of the pid_t data type, which will be used for storing a process ID.
We will invoke the pipe function to connect the two processes and pass the pp array to it. The index location pp[0] will get the file descriptor for the reading end of the pipe, while pp[1] will get the file descriptor for the write end of the pipe. The program will exit if the pipe function does not execute successfully.
Then, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access