CSCI 3120 Assignment 2
Due May 30 by 9:00 AM ADT
NOTES
You may wish to create your program using multiple files. And you may wish
to use a Makefile. If you have more than one file for this assignment, please
create a tar file containing all files needed to compile and execute your program
(including your Makefile, if you use one), and upload that tar file to
Brightspace. If you don’t use a Makefile and your program requires more than
a simple “gcc a2.c -o a2” to compile, you must include that information in
the comment at the top of your main program file. BUT in such a case you really
should use a Makefile!
As always for this course, this assignment must compile and run on the FCS
Unix server csci3120.cs.dal.ca. Do not use any of the other FCS servers
for this course.
As in A1, this program should follow the C-coding-style-notes (found in
the “Assignments and related material” folder on Brightspace.
[1] As you may know, there are lots of different command shells available for Unix-type systems;
ash, bash, csh, dash, fish, ksh, sh, tcsh and zsh immediately come to mind, but I’m sure
you can find more. For this question, you will create your own (rudimentary) shell using C. You
can create your program using any system you like, but your program must compile and run on
csci3120.cs.dal.ca; if it doesn’t, the marker is authorized to give you 0, regardless of how
much work you have put into your program.
All of the above shells are complex programs which provide many, many features. This assignment
question requires you to only implement a tiny subset of the functionality of a normal shell. Below
I list each type of command-line you are to implement, and how many points each of those pieces
is worth. Your shell should prompt the user for input with the prompt “$ ”, as seen below in the
sample commands.
In the examples below, the input typed by a user is in red, and output by the shell is in black.
Your shell should implement the following capabilities. These capabilities are explained further
below, along with simplifying assumptions that your program may make. The first few show sample
output from the executed commands, but for brevity some of the rest do not show the output. Try
the commands yourself in your shell to see the sort of output to expect.
(i) (1 point) If the command is exit, your shell terminates. This is what a terminal session which
starts your program and then immediately runs the exit command should look like (where
“
” is whatever prompt you have at your regular shell):
./a2
$ exit
1
(ii) (5 points) Run a program which takes no arguments and waitpid() for the executed program
to finish, then print another prompt and wait for another command line; examples:
$ who