Question: 5. [20 points] IPC and pipes -fifo Write a program (say prog.c) that forks and runs a sub-shell as a child process, and simply counts
![5. [20 points] IPC and pipes -fifo Write a program (say](https://s3.amazonaws.com/si.experts.images/answers/2024/08/66cde09735edb_40666cde096bba24.jpg)

5. [20 points] IPC and pipes -fifo Write a program (say prog.c) that forks and runs a sub-shell as a child process, and simply counts the number of output characters that the shell printed on the standard output. When the sub-shell terminates, the parent simply reports the number of output characters produced by the sub-shell. For parent to do its job, it needs to get everything the child shell prints on the standard output. Hope you see how a pipe will be useful here child [1:STDOUT_FILENO] -> pipe[0: STDIN FILENO] parent. Since now the parent can get everything the child writes on the standard output, the parent can count the number of characters and write them into its own standard output. You are asked to complete the following program so you can create the necessary pipe, child process and connect them as explained in the above scenario. You can ignore most of the error checking to make your solution clear, but you need to close all unnecessary file or pipe descriptors and check what read-write etc return. Also read/write one char at a time to make counting job easy! /*your simple implementation of prog.c * #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
