Computer Science 330
Operating Systems
Fall 2020, Siena College
In this programming project, you are to write a C program called the Roger Bacon Shell (rbsh), a mini command shell interpreter. rbsh 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, pipes, input/output redirection, background process management, signals, and interrupt handling, and gain extensive experience with C.
You may work alone in groups of size 2 or 3. Collaboration within a group is, of course, unrestricted. You may discuss the program with members of other groups, but what you turn in must be your own group's work. Groups must be formed no later than 4:00 PM, Friday, October 16, 2020, and be confirmed by all group members having write access to the group's repository on GitHub and all names in the README.md file. All group members will be assigned the same grade for the lab. There are many subtasks that can be carved off and assigned to group members, so everyone is encouraged to join a group.
There is a significant amount of work to be done here. It will be difficult if not impossible to complete the assignment if you wait until the last minute. A slow and steady approach will be much more effective.
To help encourage this approach, there are two parts for your work on this project. The basic functionality to run a single command is part 1, and is due at 4:00 PM, Friday, October 23, 2020. The remainder is due at 4:00 PM, Friday, October 30, 2020. Please refer to the grading guidelines at the end of this document for the specific functionality required for your part 1 submission.
Getting Set Up
You will receive an email with the link to follow to set up your GitHub repository, which will be named shell-proj-yourgitname, for this programming project. Only one member of the group should follow the link to set up the repository on GitHub, then others should request a link to be granted write access.
All GitHub repositories must be created with all group members having write access and all group member names specified in the README.md file by 4:00 PM, Friday, October 16, 2020. This applies to those who choose to work alone as well!
Requirements
Like the Unix shells you use every day, rbsh should issue a prompt (below, it is "shell#"), at which it reads commands from the user and executes them.
Your shell should interpret the following commands and provide the following functionality:
For example,
shell# cat cat.c
should execute cat with one argument, cat.c
For example,
shell# cat < cat.c > myfile.c
should cause the cat program to read from cat.c and write to the file myfile.c.
shell# ls -l >> dirlistings.txt
should cause the output of ls -l to be appended to the end of the existing file dirlistings.txt.
An individual command may only redirect input once and output once, but those redirections may be specified in any order.
shell# > alines grep -i < Makefile a
should be interpreted the same as the more usual
shell# grep -i a < Makefile > alines
shell# cat cat.c | wc > count.txt
should cause the output of cat cat.c to be the input of wc > count.txt.
shell# ls -l *.c | grep "Oct 31" | wc -l
The program should be able to handle a sequence of pipes of any length.
For example,
shell# sleep 5 & sleep 5
should launch one instance of sleep 5 in the background, then a second in the foreground.
shell# sleep 55 & ; invoke sleep in background shell# cat < hello.c ; give other commands shell# ... ; other commands shell# ... ; other commands [2] "sleep" terminated ; sleep command is done
shell# jobs PID Name [0] mycat < myfile.c > newfile.c [1] sleep 20 [4] grep mysh < doc | wc
shell# kill Usage: kill <pid> [<pid> ...]
Otherwise it kills the processes with the specified ids and displays the processes killed.
shell# kill 4 [4] "grep" Killed shell# kill 3 7 [3] "cat" Killed [7] "wc" Killed
Ideas for extra functionality include:
^
modification of previous command
<<
, >&
, |&
See builtin(1) for more ideas.
Notes
#ifdef
and #endif
directives. You can see an example
of this in the starter code.
;
- or &
-separated commands
Submission
Commit and push!
Grading
The functionality required for the first deadline is denoted by a "Part 1".
This assignment will be graded out of 100 points.
Feature | Value | Score |
Documentation | 12 | |
exit and help commands (Part 1) | 2 | |
Running a command with no arguments (Part 1) | 15 | |
Running a command with arguments (Part 1) | 10 | |
Builtin cd command (Part 1) | 2 | |
Running a command with input/output redirection | 10 | |
Launching a command in the background | 10 | |
Launching a sequence of jobs separated by semicolons or ampersands | 8 | |
Builtin jobs command | 4 | |
Builtin kill command | 3 | |
Correct trapping of Ctrl-C keystroke | 4 | |
Reporting termination of backgrounded jobs | 4 | |
Pipeline of 2 processes | 6 | |
Arbitrarily long pipeline of processes | 4 | |
Extra functionality | 6 | |
Bonus functionality | 0 | |
Total | 100 | |
Here are some possibilities for the 6 points for extra functionality. Functionality up to 10 additional points beyond the required 6 will be considered for bonus credit.
<<
, >&
, |&
,
user-specified prompts.
^
.