- Purpose: This programming assignment will reacquaint you with programming in the
Linux environment. The system calls fork, pipe, wait and signal (at least) will be used.
Required Functionality: You should develop a command-line, menu-driven program
which allows users to enter data of the following type:
Social Security Number (nine digits)
Name (no more than 80 characters)
Department (no more than 20 characters)
Home phone (10 digits)
Your program should validate that the input is in the correct format. If it is, the data will
be written to two files – emps.dat and depts.dat. Each line of the file emps.dat contains a
social security number, name, and home phone (in that order). Each line in the file
depts.dat contains a social security number and department (in that order). The files do
not have to be in sorted order, but neither file should have more than one line with the
same social security number. The menu of your program should contain choices to enter
another record and to quit the program. The program should create the data files if they
don’t exist. Appropriate error messages should be generated on error conditions.
Program Structure: Your program will be structured as three processes: one function to
process the input, and one process to verify and add the data to each of the two files. The
first process should fork the other two processes. Communication between the processes
should use pipes (not named pipes, which are a different thing). When the user chooses to
exit the program, the input processing process should send a signal to each of the two
child processes. The parent process should then wait for the two child processes to exit.
Upon receiving the signal from the parent, the two child processes should make sure that
the data file is up-to-date, close all open files and pipes, and quit. When both child
processes have exited, the parent process exits.
Extra credit: Use exec for the two child processes. In this case, you have three distinct
executable files (generated from three source files). In the regular version of the
assignment, you only need one source and one executable. If your program works
correctly with the execs, you will receive 20% extra credit.