This is a simple shell program written in C that provides basic functionality similar to bash. It supports executing commands, changing directories, handling signals, and managing background processes.
- Execute shell commands
- Change current working directory
- Handle signals (SIGINT and SIGTSTP)
- Redirect input and output
- Run processes in foreground and background
- Expand $$ to process id
To use this shell program, simply compile the shell.c file using a C compiler:
gcc --std=gnu99 -g smallsh.c -o smallshThe run:
./shellOnce the shell is running, you can enter commands just like you would in a regular shell environment. Some example commands include:
ls- List files in the current directorycd <directory>- Change the current directoryecho <message>- Print a message to the consoleexit- exit the shell
- When running a command, you can use
&at the end to run it in the background - Press
Ctrl + Zto toggle foreground-only mode. In this mode, the shell will ignore&for background processes - The shell provides feedback on the termination status of background processes