The purpose of this lab is to give gain some experience working with system calls and learn about process management (process creation, termination etc). In this lab, you will write a C program making use of several UNIX system calls. You will also need to write a design document explaining how your program is organized (details below).
The goal of this lab is to implement a simple shell in C, which will require you to use system calls directly. In class, we touched on how a few system calls (notably fork and exec) can be used to implement a command-line shell like Bash. In this exercise, you will implement closh (Clone Shell), a simple shell-like program designed to run multiple copies of a program at once.
Like any other shell, closh takes as input the name of the program to run (e.g., hostname, pwd, echo, etc.). However, closh also takes three additional inputs:
Closh executes the given program the specified number of times, then returns to the prompt once all processes have either completed or timed out. Here is a simple example of using closh:
bemurphy@elnux2$ ./closh
closh> hostname
count> 3
[p]arallel or [s]equential> p
timeout> 5
elnux2
elnux2
elnux2
closh>
Additionally, each new process your program creates should print its process ID before executing the command, as well as any other output you would like that demonstrates how your program is operating.
We will provide a program skeleton (closh.c) that implements all required parsing and interface logic. The skeleton simply executes the given command once and exits. Your task is to replace this single system call with the real process logic of closh.
Run the following commands to download the starter files on EDLAB. While you are welcome to write code on your own machine, we will be evaluating your code on the EDLAB machines, so please make sure your final submission runs on EDLAB.
$ wget http://lass.cs.umass.edu/~shenoy/courses/377/labs/lab1/closh-starter.tar.gz
$ tar xzvf closh-starter.tar.gz
Once you have written your version of the shell, write a design document that documents your design choices.
All of the following files must be submitted on Moodle as a zip file in the form FirstnameLastname.zip to get full credit for this assignment.
You should be very careful about using code snippets you find on the Internet. In general your code should be your own. It is OK to read tutorials on the web and use these concepts in your assignment. Blind use of code from web is strictly disallowed. Feel free to check with us if you have questions on this policy. And be sure to CLEARLY document any Internet sources/ tutorials you have used to complete the assignment in your README file.
(max 100) Total Grade
Late Policy: Lab 1 is due at 8 PM on Thursday, October 2. Please refer to the course syllabus for late policy on lab assignments. This late policy will be strictly enforced. Please start early so that you can submit the assignment on time.