Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SYSTEM CALLS FOR I/0 The idea of this exercise is to communicate between a child and a parent using a shared file that the user

SYSTEM CALLS FOR I/0

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:

  1. Check that the number of command line arguments is 2. If it isn't, produce an error message. Note: you cannot use perror here.
  2. 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
  3. Don't forget to handle the error situation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

Explain the micro-assessment of country risk.

Answered: 1 week ago