To develop a C program that uses both fork() and pipe() process system calls to implement interprocess communication by means of file sharing.
You are to use the Ubuntu operating system to create two C programs. A program consumer.c to read from a file containing integers and to write to the display only the even numbers found in the input file. A program producer.c to create a file and write 20 integers to this file. Both programs, the producer and the consumer, will communicate by means of reading and writing to the file through a shared pipe. Your solution must include a child process which will execute your consumer program. Your shared file should be named numbers and should be the only means of sharing information between your producer and consumer programs. You may use the fork(), pipe(), dup(), dup2(), read(), write(), creat(), as well as any of the exec() family of system calls.
You are to submit to Blackboard the following:
1) Your source code for the producer and the consumer, as well as any output produced by your solution that clearly shows the following:
1) The contents of the file numbers, and
2) information about both parent and child pids as well as the file descriptor fd of your numbers file, and the display output of your consumer program. You are to use the following format to structure your output:
a) File numbers fd = fd-of-numbers.
b) File numbers contents is: a listing of the 20 integers.
c) A screen shot of your terminal showing the even numbers returned by your consumer program.
d) Parent: My pid = pid-of-parent. I created child pid = pid-of-child.
e) Child: My pid = pid-of-child. My parent pid = pid-of-parent.
Note that in d) Parent is to indicate that the output produced was generated by the parent process. In a similar way, in e) Child indicates that the output was generated by the child process.