3.9 UNIX Processes

In C, write a program that spawns a child process, does inter-process communication, and displays process information.

Each line of output of your parent process must be prefixed with PARENT: . Each line of output of your child process must be prefixed with CHILD: . Prior to each step, your program must output an information line formatted as follows:

About to perform step #.

Your parent program must:
  • Display a process information report.

  • Create a unnamed pipe, using pipe.

  • Spawn a child process that inherits the pipe, using fork.

  • Write a string to the pipe.

  • Exit with success.

Your child program must:
  • Display a process information report.

  • Read the parent’s string from the pipe and display it.

  • Get its parent process ID, using getppid, and display it.

  • Exit with success.

The process information report must be in the following format:

Process ID is:            15550

Process parent ID is:     26778

Real UID is:              1004

Real GID is:              4000

Effective UID is:         1004

Effective GID is:         4000

Process priority is:      0

This information comes from getpid, getppid, getuid, getgid, geteuid, getegid, and getpriority.

Your program should have no other output.

You must turn in
  • A README file that contains a short write-up of your project. It should discuss the approach you took to solving the problem, it should discuss any problems or issues that still remain, it should discuss any interesting things that you learned in the course of the project. Finally, it should provide the grade you believe the project deserves with a detailed explanation of why. This explanation should almost certainly focus on why you believe the program is correct.

    This file must be in plain-text. If you need formatting, use Markdown. It must be limited to 80 characters wide, unless you are quoting program output.

  • Your source code, named a7.c.

  • A test output file, named test.out, that contains the expected output.

  • A Makefile that first builds the program and then tests it by running it and compares the actual output to test.out. You should not be able to predict the PIDs, so diff should report a few lines different.

This assignment will be graded based on its correctness and your ability to articulate why it is correct.