A fully functional Unix shell implemented in C, supporting process management, job control, signal handling, redirection, piping, and command history.
- Process Creation & Execution (
fork(),exec(),wait()) - Foreground & Background Process Management (
&support) - Signal Handling (
SIGCHLD,SIGINT,SIGTSTP) - Built-in Commands (
cd,exit) - Input & Output Redirection (
<,>) - Piping (
|) - Command History (using
readlinelibrary) - Tab Auto-Completion (via
readline)
git clone https://github.com/your-username/custom-shell.git
cd custom-shellgcc -o custom_shell custom_shell.c -lreadline./custom_shellβ Running Basic Commands
custom-shell$ ls -l
custom-shell$ echo "Hello, Unix Shell!"β Background Execution
custom-shell$ sleep 10 &
[Background Job] PID: 12345β Job Control (Foreground & Background)
custom-shell$ fg 12345 # Brings process 12345 to foreground
custom-shell$ bg 12345 # Resumes process 12345 in backgroundβ Input & Output Redirection
custom-shell$ cat < input.txt
custom-shell$ ls > output.txtβ Piping
custom-shell$ ls | grep ".c" | wc -lβ Built-in Commands
custom-shell$ cd /home/user
custom-shell$ exitβ Command History & Auto-Completion
- Use Arrow keys (Up/Down) to browse history.
- Type part of a command and press Tab for auto-completion.1οΈβ£ Process Creation & Execution
- Uses fork() to create child processes.
- Executes commands using execvp().
- Waits for foreground processes using waitpid().
2οΈβ£ Signal Handling
- SIGINT (Ctrl+C): Terminates foreground processes.
- SIGTSTP (Ctrl+Z): Sends process to background.
- SIGCHLD: Handles background process termination.
3οΈβ£ Redirection (<, >)
- Redirects standard input/output using dup2() and open().
4οΈβ£ Piping (|)
- Implements inter-process communication via pipe().
- Spawns multiple child processes and connects input/output streams.
5οΈβ£ Built-in Commands
- cd (change directory)
- exit (terminate shell)
This project is licensed under the MIT License.
Srinath Duvvuri π§ duvvurisrinath@gmail.com