Lab 5 - Writing your own shell
Lab 5 is due 11:59 pm, Friday Nov 2
Notes and Clarifications
- Thu Oct 31 2:45pm
- IMPORTANT: Grading policy change:
Well... based on your experiences, it looks like my fancy
checktsh.pl autograder doesn't work consistently enough to
be used for real autograding. Sigh... Here's what we'll do:
For grading, I won't require exact correspondence with the
reference solution. For a particular trace, if your solution matches
the reference solution exactly, then you get full credit. If it doesn't
match, I'll run your shell and do the trace interactively and see
if it seems to be doing the right thing. As always, the reasonable
person principle applies, so I'll try to do the right thing when
I assign the grades.
If you encounter an error message when run you sdriver.pl
such as "open2: exec of tshref -p failed at ./sdriver.pl",
the fix is to make sure that the current working directory (".")
is in your PATH. On bash, do "export PATH=$PATH:. " and for
tcsh do "setenv PATH .:$PATH" (you don't actually type the
double quote marks).
There is a new version of checktsh.pl in the L5 directory
that works correctly for those of you who don't have "." in
your PATH variables.
- Wed Oct 31 11:30pm
- I put a script called "checktsh.pl" in the L5
directory that you can use to
compare your results to the reference solution. Your
solution should pass this script to get full credit.
By default checktsh.pl runs tshref and tsh on all traces and
compares the results (modulo PIDs and ps output).
The -t argument compares the results of 1 trace.
The -v argument gives you a detailed trace.
The -h argument prints the usage.
- In order to display messages such as
"stopped by signal: Interrupt" you'll need to use
sprintf() to construct a string, and then pass
this string to psignal().
- If you want to print a '%' character, use "%%" in the
printf format string.
- The challenging part of this Lab is in the design of waitfg() and
sigchld_handler(). The key issue is how to partition the
handling of stopped and terminated between these two functions.
One approach is to have sigchld_handler() do all the work
of waiting, reaping and responding to stopped and terminated
background and foreground jobs, with waitfg() simply stalling
until the state of the foreground job entry in the job list changes
from FG to something else, or disappears from the job list.
Another approach might partition the work so that
sigchld_handler() consults the job list and only waits
for background children, and waitfg only waits for foreground
children. Other approaches are possible too.
The point is that you want to think very carefully about the
design of these two functions.
- The -v (verbose) option of tshref program is
there to help you see what is happening. Your code does
NOT have to produce similar output. I'll be checking the
output of your solutions without the -v option.
- Sun Oct 28 11:30am
Your handin must be a SINGLE tsh.c file that compiles cleanly with
"gcc -Wall -O2 -o tsh tsh.c". Please don't create any additional
.h or .c files for this assignment.
- The constants and structures in tsh.c are advisory. You may
modify tsh.c any way you like.
- Earlier versions of tsh.c had a typo in parseline().
The "char array[MAXLINE]" array should be declared as
"static char array[MAXLINE]"
This has been fixed in L5.tar.
- Sat Oct 27 7:30pm
- If you don't have "." in your path, then in Makefile you
can change "DRIVER = sdriver.pl" to "DRIVER = ./sdriver.pl".
- The original version of "trace10.txt" had a race that caused
an occasional error message from the shell.
- The latest L5.tar file fixes both of these
problems. Be careful not to expand the tarfile in your working directory
or you'll overwrite your tsh.c file.
Last modified: Fri Oct 26 20:28:49 EDT 2001