A Unix shell built from scratch in C++, implementing core shell functionality including command parsing, process creation, and child process management using POSIX system calls.
- Execute standard Linux commands (e.g.
ls,pwd,cd,echo) - Fork/exec model for child process creation
- Custom
ChildProcessclass for process lifecycle management - Graceful handling of invalid commands and error states
- Clean prompt loop with exit support
The shell runs a read-eval-print loop (REPL):
- Displays a prompt and reads user input
- Parses the command and arguments
- Forks a child process using
fork() - Executes the command in the child via
execvp() - Parent process waits for the child to finish before prompting again
The ChildProcess class encapsulates the forking and execution logic, keeping the main shell loop clean and readable.
Requirements: Linux or WSL, g++ (C++11 or later)
g++ -o shell customLinuxShell.cpp ChildProcess.cpp
./shell$ ./shell
> ls
ChildProcess.cpp ChildProcess.h customLinuxShell.cpp README.md
> echo hello world
hello world
> exit
Building this project gave me hands-on experience with:
- POSIX process management (
fork,execvp,waitpid) - Low-level C++ memory and string handling
- Separating concerns with class-based design in systems code