TDC 368: Unix and Network Programming, Spring 02
Assignment 2: Unix Signals
Due: 4:30pm April 28, 2002
Assignment Description
Write a C/C++ program (P)
that forks another child (C) program, prints its own PID and the Child PID,
open a file given in the command-line argument, write a line in the file (“I AM
THE PARENT\n”), closes the file, sends SIGUSR1 to C, and then P waits until C
sends a SIGUSR1. Once the C program starts, it waits for SIGUSR1 signal. Upon
receiving this signal, C program prints its own PID and the parent (P) PID,
open the same file, write one line into the file (\223I am the Child\n\224), closes the file, and then C
sends SIGUSR1 to P and goes back to wait for SIGUSR1 from P. This alternate
writes in the file continues till the user hit Ctr-C three times which causes
both programs to terminate. The program will be executed as follows:
CoordWrite <FileName>
Submission
Procedure:
Write your name and SSN in the main program and in the README file. After cleaning your directory from objects and bin files, do the following: (Your submission must contain a Makefile and a README file that describes how to run your program). Then USE the same naming convention and command line arguments as specified in the assignment description.
$ tar
-cvf <HawkLogin>-<SSNLast4>-hw2.tar *
$gzip <HawkLogin>-<SSNLast4>-hw2.tar
DO
NOT for get to take out any binary or object files in your submission
Then submit it in DLWEB .
Grading Policy
Late penalty is 10% per day.