This is a simple unix shell with job control capabilities.
It was implemented as an exercise for better understanding the handling of processes and signals in unix/linux and the underlying mechanisms of job control.
The initial code is part of the Shell Lab and follows Chapter 8: Exceptional Control Flow of the book Computer Systems's - A Programmers Perspective.
The main implementation is on file tsh.c
. The other files are provided from the handouts for the lab. If you want to try it yourself, get it here.
- Built-in commands:
quit
,jobs
,fg
,bg
- Run external programs (absolute path only)
- Can start processes on the background with
&
jobs
lists status of jobsfg
andbg
accept process id (e.g.fg 12345
) or job id (e.g.bg %2
)- Correctly handles Ctrl+C (interrupt), Ctrl+Z (stop) and all signaling on child processes and process groups
- Developed/tested on Linux
- GCC
- Make
- Perl (only to run the
sdriver.pl
test script)
$ cd src
$ make clean
$ make # compile the shell and auxiliary programs
$ make testXX # run test number XX
$ ./tsh # run the shell interactively
$ ./tshref # run the REFERENCE shell for comparison
Check src/README
for more options.
For a shell implementation with a more complete set of features check: