Unix Programming

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.

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.