You may work individually or in groups of two or three on this project. Groups must be formed by Tuesday, October 8.
Introduction
For this project you will write a C program called the Cow Shell (cowsh), a mini command shell interpreter. cowsh is similar to familiar Unix shells such as the Bourne shell (sh) the Bourne-Again shell (bash), and C shell (csh, tcsh). You will learn about process creation, implementation of pipes, input/output redirection, background processes, signals, interrupt handling, and the use of some system calls.
Description
Like the familiar Unix shells, cowsh should issue a prompt (perhaps "cowsh#"), at which it reads commands from the user and executes them. When the user issues the exit command, cowsh should terminate.
Your shell should interpret the following commands:
For example,
cowsh# run cat cat.cshould execute cat with one argument, cat.c
For example,
cowsh# run cat < cat.c > myfile.cshould cause the cat program to read from cat.c and write to the file myfile.c.
For example,
cowsh# run cat cat.c | wc > count.txtshould cause the output of cat cat.c to be the input of wc > count.txt.
You may wish to make the run part of this command optional, allowing programs to be executed by cowsh in a more familiar manner - by simply typing the command.
cowsh# bg sleep 55 ; invoke sleep in background cowsh# run cat < hello.c ; give other commands cowsh# ... ; other commands cowsh# ... ; other commands [2] "sleep" terminated ; sleep command is done
You may wish to use the more traditional & at the end of a command to provide backgrounding of processes.
cowsh# jobs PID Name [0] mycat < myfile.c > newfile.c [1] idle 20 [4] grep cowsh < doc | wc
cowsh# kill kill <pid> [<pid> ...]
Otherwise it kills the process with the specified ids and displays the process killed.
cowsh# kill 4 [4] "grep" Killed cowsh# kill 3 7 [3] "cat" Killed [7] "wc" Killed
Implementation Notes
Grading
The project will be graded out of 75 points, and will be based on correctness, design, documentation, and style. An on-time submission that correctly implements and documents the required features can earn up to 65 points. The remaining 10 points are for the implementation and documentation of additional features of your choosing. Late submissions are not eligible for credit for additional features.
Submission
By 12:01 AM, Thursday, October 17, 2002, You should submit a file cowsh.tar that includes the following:
Honor Code Guidelines
Collaboration within a group is unrestricted. You may ask the instructor or teaching assistant for help. Outside help (classmates, friends, reference manuals) with the programming language (syntax) or computer systems is permissible, but help with the design of your program is restricted to your group members, the instructor, and the teaching assistant. Outside references such as language manuals are permitted. Any other collaboration or consultation is prohibited and will be considered a violation of the Honor Code. If you wish to use or refer to any software libraries or outside source code beyond the standard C libraries, check with me first. If in doubt about anything related to Honor Code, ask now and avoid problems later!