PROJECT SPECIFICATION DOCUMENT
Design and Build a Unix-like Command Line Shell in Modern C++
1. Project Overview
This project defines the design and implementation of a Unix-like interactive command-line shell for
Linux using modern C++ and POSIX system calls.
The shell must function as a standalone system-level executable capable of interpreting user
commands, spawning processes, managing execution flow, and handling inter-process
communication.
The project demonstrates mastery of Linux process control, file descriptors, piping, redirection, and
systems architecture.
2. Problem Statement
Linux systems require a command interpreter capable of:
- Receiving user input
- Parsing command structures
- Spawning and managing processes
- Coordinating inter-process communication
- Handling terminal signals
This project engineers such a system from first principles.
3. Final Deliverable Definition
A fully functional interactive shell executable.
Example interface:
myshell>
The shell must behave as a working command-line interpreter.
4. Functional Requirements
4.1 Interactive Prompt Must continuously accept user input.
4.2 External Command Execution Must execute system binaries (ls, pwd, date, etc.).
4.3 Argument Handling Must support arguments such as: ls -la, echo hello world.
4.4 Built-in Commands Required: cd, pwd, clear, help, exit with correct behavior.
4.5 Input Redirection Support '<' for stdin redirection.
4.6 Output Redirection Support '>' and '>>' for output handling.
4.7 Pipes Support single pipe operations (cmd1 | cmd2). Multi-pipe optional extension.
4.8 Background Execution Support '&' for background process execution.
4.9 Signal Handling Must handle Ctrl+C without terminating shell.
4.10 Command History Must store session command history.
5. Technical Constraints
Implementation must use:
- C++17 or newer
- Linux system calls
- POSIX APIs
Prohibited:
- external shell frameworks
- execution wrappers abstracting process control
All shell behavior must be manually implemented.
6. System Architecture Requirements
Modules:
Input Manager: handles user input
Parser: tokenizes and interprets commands
Executor: runs commands
Built-in Manager: handles internal commands
Process Controller: manages fork/exec/wait
Signal Handler: manages SIGINT
History Manager: stores commands
7. Behavioral Specifications
Invalid commands must not crash the shell.
Redirection failures must produce errors and continue execution.
Permission errors must be displayed clearly.
Background processes must not block the shell.
Shell must remain stable under repeated use.
8. Acceptance Criteria
Project is complete only if:
- external commands execute correctly
- all built-ins work
- pipes function
- redirection works
- background processes supported
- signal handling stable
- no crashes under stress
- no memory leaks
9. Testing Requirements
Test cases include:
- simple commands (ls, pwd)
- arguments
- redirection
- pipes
- background execution
- Ctrl+C behavior
Each must pass expected output validation.
10. Failure Conditions
Project fails if:
- zombie processes remain
- shell crashes unexpectedly
- pipes deadlock
- file descriptors leak
- child processes orphan incorrectly
11. Recommended Project Structure
src/, include/, tests/, docs/
Modules separated by responsibility.
12. Required Technical References
The Linux Programming Interface - Michael Kerrisk
Advanced Programming in the UNIX Environment - Stevens & Rago
Linux man pages: fork, execvp, waitpid, pipe, dup2, signal
13. Completion Checklist
All features implemented
No memory leaks
Stable execution
Correct process handling
Signal handling correct