Programming Assignment 4

Adding More Features to the Shell

Objective

The main objective of this assignment is to add more functionalities to your shell from Programming Assignment 3. So the first step is to get your shell from Programming Assignment 3 working. You may use this shell as the code base for developing Programming Assignment 4.

The assignment introduces background process, file redirection, pipe, and programming with POSIX threads (pthreads), including mutual exclusion with pthreads. Experience with some more system calls and C library functions will also be done to hone your programming skills. Reading of man pages will also be a must to do well.

Try sample code to experiment more.

The Assignment

Test Runs

To test '&', show running some commands in the background in your script. To test watchuser, come up with your own tests. The TAs will test each feature.

Test your shell by running the following commands in it (in order): (ignore all the watchmail commands)

    pwd
ls &
ls -l &
cd /
sleep 20 &
ls & ; run before sleep is done
pid
tty
/bin/ps -lfu USERNAME ; replace USERNAME with your own
cd
cd [project test dir of your choosing]
pwd
ls -l
rm -f test1 test2 test3 test4 test5 test6 test7 test8
./test-1+2 > test1
./test-1+2 >> test2
./test-1+2 >& test3
./test-1+2 >>& test4
cat test1 test2 test3 test4
./test-1+2 > test1
./test-1+2 >> test2
./test-1+2 >& test3
./test-1+2 >>& test4
cat test1 test2 test3 test4
noclobber ; turn noclobber on
./test-1+2 > test5
./test-1+2 >> test6
./test-1+2 >& test7
./test-1+2 >>& test8
cat test5 test6 test7 test8
./test-1+2 > test5
./test-1+2 >> test6
./test-1+2 >& test7
./test-1+2 >>& test8
cat test5 test6 test7 test8
grep hello < test8
grep error < test8
rm -f test9 test10 test11 test12
noclobber ; turn noclobber off
./test-1+2 > test9
./test-1+2 >> test10
./test-1+2 >& test11
./test-1+2 >>& test12
cat test9 test10 test11 test12
ls | fgrep .c ; show pipes works
./test-1+2 | grep hello
./test-1+2 |& grep hello
./test-1+2 | grep output
./test-1+2 |& grep output
./test-1+2 |& grep error
pid ; zombie avoidance checking
/bin/ps -lfu USERNAME | grep defunct ; replace USERNAME with your username

Grading

Turn In

You need to tar up your source code and submit the tar file so that your shell can be tested and graded. To do this,