▄▄▄ ██████ ▄▄▄█████▓ ██▀███ ▄▄▄ ██████ ██░ ██ ▓█████ ██▓ ██▓
▒████▄ ▒██ ▒ ▓ ██▒ ▓▒▓██ ▒ ██▒▒████▄ ▒██ ▒ ▓██░ ██▒▓█ ▀ ▓██▒ ▓██▒
▒██ ▀█▄ ░ ▓██▄ ▒ ▓██░ ▒░▓██ ░▄█ ▒▒██ ▀█▄ ░ ▓██▄ ▒██▀▀██░▒███ ▒██░ ▒██░
░██▄▄▄▄██ ▒ ██▒░ ▓██▓ ░ ▒██▀▀█▄ ░██▄▄▄▄██ ▒ ██▒░▓█ ░██ ▒▓█ ▄ ▒██░ ▒██░
▓█ ▓██▒▒██████▒▒ ▒██▒ ░ ░██▓ ▒██▒ ▓█ ▓██▒ ▒██████▒▒░▓█▒░██▓░▒████▒░██████▒░██████▒
▒▒ ▓▒█░▒ ▒▓▒ ▒ ░ ▒ ░░ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░ ▒ ▒▓▒ ▒ ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒░▓ ░░ ▒░▓ ░
▒ ▒▒ ░░ ░▒ ░ ░ ░ ░▒ ░ ▒░ ▒ ▒▒ ░ ░ ░▒ ░ ░ ▒ ░▒░ ░ ░ ░ ░░ ░ ▒ ░░ ░ ▒ ░
░ ▒ ░ ░ ░ ░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
ASTRA Shell is a Linux-compatible Unix shell written in C++ that implements core POSIX shell features including job control, signal handling, process groups, foreground/background execution, and pipelines.
This project was built incrementally to understand how real shells interact with the kernel, focusing on correctness over convenience.
- Interactive prompt (
astra$) - Command execution via
fork()+execvp() - PATH-based command lookup
- Graceful shell exit
cd [dir]— change directorypwd— print current directoryjobs— list active jobsfg %n— bring job to foregroundbg %n— resume job in backgroundexit— exit the shell
- Foreground and background execution (
&) - Process groups (PGID-based job tracking)
- Terminal ownership management via
tcsetpgrp - Correct handling of:
Ctrl+C→ terminate foreground jobCtrl+Z→ stop foreground job
- Resume stopped jobs using
fg/bg - Zombie-free execution
- Shell ignores interactive signals (
SIGINT,SIGTSTP,SIGTTOU,SIGTTIN) - Child processes restore default signal behavior
SIGCHLDhandled safely (no logic inside handlers)
- Arbitrary-length pipelines using
| - Correct stdin/stdout redirection via
pipe()anddup2() - Entire pipeline treated as one job
- Pipelines fully support:
Ctrl+CCtrl+Zfg/bg- background execution
Example:
ls | grep cpp | wc -lRequirements :
- Linux or WSL2
- C++17 compatible compiler
- POSIX environment
mkdir build
cd buid
cmake ..
make./astra
- I/O redirection (> < >> 2>)
- Environment variables (export, $VAR)
- Command history / line editing
- /proc-based memory awareness (planned)
- Scripting support
ASTRA Shell was built as a systems programming exercise to deeply understand:
- Unix process model
- Job control internals
- Terminal behavior
- Signal semantics
How real shells like bash actually work