3.1 Basic Processes
In C using UNIX system calls, write a program that demonstrates inter-process interaction. The program may spawn another process. We will refer to the first program as the "parent" and the second as the "child".
About to perform step #. |
If your parent program receives an argument on the command-line, it must:
Display a process information report.
Create a unnamed pipe, using pipe.
Spawn a child process that inherits the pipe, using fork.
Read from the pipe (to synchronize with the child).
Send the child a SIGTERM signal with kill.
Wait for the child to terminate, with wait, and report the child’s exit status.
Exit with success.
If your parent program does not receive an argument on the command-line, it must:
Display a process information report.
Exit with success.
Display a process information report.
Setup a signal handler with sigaction for the SIGTERM signal that replaces the child program with an instance of the parent program, without a command-line argument using execl.
Write a message to the inherited pipe, to synchronize with its parent.
Enter an endless loop that never returns.
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.
Your repository must contain the following files:
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 a1.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.