

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A programming assignment for cs 350, a university course, where students are required to write a program using parent-child cooperation in unix. The program offers a menu for users to display the current date and time, the calendar for the current month, list files in the current directory, or quit the program. For each choice other than quit, the parent process creates a child process to execute the requested unix command using system(...). The child process terminates upon execution of the command, and the parent process waits for it to terminate before displaying the menu again. The document also includes instructions for submission and academic honesty.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Write a program, based on parent-child cooperation, where the parent process offers the program user a menu whose options are to:
upon the execution of a single UNIX command, the child process terminates (dies). Before displaying the menu again, the
parent process terminates.
When writing the program, make sure that you display the identification number of the process that displays the information. So, for example, a suggested output of a run of your program should look similar to the following:
Parent process ID: 2765, Parent's parent ID: 904 Choose the function to be performed by the child: (1) Display current date and time (2) Display the calendar of the current month (3) List the files in the current directory (4) Exit from the program
Enter your choice: 1 Child process ID 2766; Parent ID 2765 Fri Nov 26 17:36:25 EST 1999
Current process PID 2765 Choose the function to be performed by the child: (1) Display current date and time (2) Display the calendar of the current month (3) List the files in the current directory (4) Exit from the program
Enter your choice: 3 Child process ID 2774; Parent ID 2765 total 18 -rwxr-xr-x 1 cukic 5093 6740 Nov 26 16:58 a.out -rw-r--r-- 1 cukic 5093 1150 Nov 26 16:59 a3.c
Current process PID 2765 Choose the function to be performed by the child: (1) Display current date and time
(2) Display the calendar of the current month (3) List the files in the current directory (4) Exit from the program
Enter your choice: 2 Child process ID 2797; Parent ID 2765 December 1999 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Current process PID 2765 Choose the function to be performed by the child: (1) Display current date and time (2) Display the calendar of the current month (3) List the files in the current directory (4) Exit from the program
Enter your choice: 4
Current process PID 2765 Program terminated
Of course, every time you run your program, the process ID numbers will be different, reflecting the run-time assignment of
well described in one of the recommended textbooks ("UNIX Systems Programming, see the reference in the sylabus"). For
textbook. The following header files should most likely be included in your programs:
#include <stdio.h> #include <sys/types.h> #include <unistd.h>
In order to be graded, you must submit the following:
Each student is expected to develop his/her assignment alone. Do not share programs, or program parts, with your colleagues. Violators of this policy will be held responsible for academic dishonesty, and will bear consequences in accordance to the rules and regulations of West Virginia University.