Question
The idea of this exercise is to communicate between a child and a parent using a shared file that the user will specify. Your program
The idea of this exercise is to communicate between a child and a parent using a shared file that the user will specify. Your program will require the name of the file to be sent as a command line argument (argv[1]) A skeleton algorithm is provided below: Check that the number of command line arguments is 2. If it isn't, produce an error message. Note: you cannot use perror here. Use "fork" to produce a child and parent Child will: open the file for writing (make sure to use the "create" flag and permissions for the user to read and write) check for errors on opening and use perror to describe the error. read from standard input (until end of file,ie., you type CTRL-D) write to the file when done, close the file Parent will: "wait" for the child open the file for reading check for errors on opening and use perror to describe the error. write a message that you are in the parent read from the file (until end of file) write to standard output when done, close the file Don't forget to handle the error situation.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started