% ./ash $ ls -al drwxr-xr-x 2 dm classadm 512 Oct 27 2003 . drwxr-xr-x 7 dm classadm 2560 Sep 10 23:32 .. -rw-r--r-- 1 dm classadm 2858 Oct 27 2003 .cshrc -rw-r--r-- 1 dm classadm 212 Jan 12 2001 .login -rw-r--r-- 1 dm classadm 105 May 13 2000 .mailrc -rw-r--r-- 1 dm classadm 264 Jan 16 2001 .profile -rw-r--r-- 1 dm classadm 126 Sep 17 2003 .rhosts -rw-r--r-- 1 dm classadm 2110 Sep 11 00:01 ash.c -rw-r--r-- 1 dm classadm 2110 Sep 11 00:02 ash $ echo hello hello $In addition to running simple commands, your shell must support the following features:
Before printing the prompt, however, your shell should check to see if any background processes have exited. If so, it should print the process ID and "Done" if the process exited with zero, or "Done (N)" if the process exited with value N, or "Killed (N)" if the process was terminated with signal N. You may find the sleep and kill commands useful for debugging this feature. For example:
% ./ash $ sleep 20 & 27717 $ kill 27717 27717 Killed (15) $ sleep 1 & 19624 $ [type return after one second] 19624 Done $ false & 31190 $ [return] 31190 Done (1) $
% ./ash $ echo test >test-file $ cat test-file test $
% ./ash $ echo test >test-file $ cat < test-file test $ cat < test-file > test-file-2 $ cat < test-file2 test $
% ./ash $ echo test | cat test $ echo test > test-file $ cat < test-file | cat test $ cat < test-file | cat | cat test $
% cc -ansi -Wall -o ash ash.c % ./ash $The whole lab should only require about 250 lines of code to implement.
If you are stuck, and would like some help getting started, you can download and examine this partially implemented shell. This partially implemented shell supports executing programs and input and output redirection. However, it does not support pipes or background processes.
% script Script started, output file is typescript % ./ash $ ... $ ^D % ^D Script done, output file is typescript % cp ash.c typescript ~class/handin/lab1/`logname`/ %If you have any problems with submission, please contact the TA or instructor.
In particular, you may find the following man pages helpful:
(The parenthesized number says which section of the manual contains the documentation; do not actually give that number to the man command.)