CMPS 105: Systems Programming

Programming Assignment #4: A Simple Shell

Due Monday, May 10, 2004


Remember: your programming assignment must be turned in online.

The Basics

The goal of this assignment is to get familiar with process control.

In this assignment, you are to implement a simple shell program. It will print a prompt, then read in whatever the user types and try to execute it assuming that it is a program, then print out the prompt, ..., etc.

Your shell should do three things:

  1. Pass any parameters to the called program
  2. Wait for the called program to finish
  3. Implement one other feature of your favorite shell (be sure to discuss it in your design doc)

For extra credit you may also:

  1. Implement '&' to allow your shell to continue without waiting for the called program to finish (note that you have to do a wait at some point so that the called program doesn't become a zombie).
  2. Implement '>', '<', and '|' to redirect output to a file, input from a file, or output to the input of another program
  3. Implement ';' to allow more than one command on the same line
  4. Implement any other shell feature such as command history or whatever you like


The Details

To implement your program, you will need to use the systems calls that manage processes: fork(), execv(), wait(), and exit().

My advice is to implement this program as follows:

1. Get it to work with programs that take no parameters (e.g., ls)

2. Get it working with parameters

3. Add one other feature

Note: You may not use the system() function.


What to turn in

Your code, a working makefile, and your design document. In addition, include a README file to explain anything unusual to the TA — testing procedures, etc.

REMEMBER: Do not submit object files, assembler files, or executables. Every file in the submit directory that could be generated automatically by the compiler or assembler will result in a deduction from your programming assignment grade.


sbrandt@cse.ucsc.edu