C Shell is a small shell program written in C that implements features from well known shells, such as bash. It is the portfolio piece for CS 344 (Operating Systems) at Oregon State University.
Author: Melissa Lagunas
The general syntax of a command is the following:
command [arg1 arg2 ...] [< input_file] [> output_file] [&]
The items in square brackets are optional, and the &
is also optional.
The following functionality is implemented:
- User is provided with a prompt
$:
for running commands - User can insert blank lines and comments, which are lines beginning with the
#
character. The shell will reprompt the user for a new command if these characters are inserted. - User can expand the variable $$ to retain the process id of the current command.
- User can execute the commands
exit
,cd
, andstatus
via code built into the shell.status
will return the exit status of the most recent foreground process. - User can execute other commands, which are implemented by creating new processes using a function from the
exec
family of functions - User can execute input and output redirection
- User can run commands as foreground or background processes, using the symbol
&
to indicate that a command should be executed in the background. - User can use custom signal handler
SIGINT
(CTRL-C) (child foreground processes only). This process will terminate itself upon receipt of this signal. - User can use custom signal handler
SIGSTP
(CTRL-Z) (parent processes only).- If a parent process running the shell receives this signal, the shell will display an informative message to the user. The shell will then enter a state where subsequent commands can no longer be run in the background.
- If the user enters
SIGSTP
again, the shell will display another informative message and return back to normal condition, where the&
operator will be honored for subsequent commands and allow for execution of background processes.