Lab Assignment--System Calls for I/0

Exercise Description

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

  3. Don't forget to handle the error situation


Submit 2 files to URCourses

  1. Your Code
  2. Script containing the following commands (executable is called myIO):
    1. ls -l (Goal: show that no .txt files exist)
    2. myIO (Result: error message-not enough arguments)
    3. myIO file.txt (Result: no errors; runs to completion and creates file.txt)
    4. ls -l (Goal: show that file.txt has been created)
    5. cat file.txt (Goal: display the contents of the output file)
    6. myIO /file.txt (Result: two error messages - (1) permission denied on creating and (2) no such file when opening for reading- on file.txt in the root directory)