This assignment is intended to introduce you to the process manipulation
facilities in the Unix
Operating System. You are to implement the program
described below on any CCC DEC machines.
You are to write a program doit that takes another command as an
argument and executes that command. For instance, executing:
% doit cat /etc/motd
would invoke the cat command on the file /etc/motd,
which will print the current ``message of the day.'' After
execution of the specified command has completed, doit should
display statistics that show some of system resources the command
used. In particular, doit should print:
Satisfactory completion of the basic objective of this assignment is
worth 13 of the 15 points. For the additional two points, your program
should be extended to behave like a shell program if no arguments
are given at the command line. Your program should continually prompt for
a command (which may have multiple arguments separated by white space) then
execute the command and print the statistics. This work will involve
breaking the line of text you read into an argument list. Your program
should continue to read and execute commands until the command exit
is given or the end-of-file is reached. Note: you may not use the system
call system available in Unix to execute the entered command. A
sample session is given below with comments given in <>.
% doit
==>ls
< listing of files in the current directory >
< statistics about this ls command >
==>cat /etc/motd
< print the current message of the day >
< statistics about this cat command >
==>exit
% < back to the Unix prompt >
You should also observe how your mini-shell works in comparison to a regular Unix shell. Does it have all the same features? What limitations does it have? You should include your observations as a comment in your code that is turned in.
The following system calls might be useful:
To get help information about these routines, use the Unix ``man'' command. For instance, entering ``man fork'' will display the manual page entry for fork on the terminal. The manual pages are organized into sections. Section 1 is for Unix commands, section 2 is for Unix system calls and section 3 is for Unix library routines. Some entries are contained in more than one section. For example to obtain information about the system call wait() (rather than the command wait) use ``man 2 wait'' where the section is explicitly given.
Submit your assignment for grading as directed in class.