MiniShell is a custom Unix-like command-line shell developed in C to understand and implement the core concepts behind a Linux shell.
The project goes beyond simple command execution and implements process creation, external command execution, N-level pipelines, signal handling, and basic foreground/background job control.
The shell uses Linux/POSIX system calls and C programming concepts to manage processes and communication between them.
| Feature | Implementation |
|---|---|
| 🖥️ Custom Shell Prompt | Customizable prompt with terminal colors |
| ⚙️ Internal Commands | cd, pwd, echo, exit |
| 🚀 External Commands | fork() + execvp() |
| 🔗 N-Level Piping | Multiple commands connected using pipe() |
| 📡 Signal Handling | SIGINT, SIGTSTP, SIGCHLD |
| ⏸️ Process Suspension | Ctrl + Z |
| 🛑 Process Termination | Ctrl + C |
| 📋 Job Management | Singly Linked List |
| ⬆️ Foreground Jobs | fg |
| ⬇️ Background Jobs | bg |
| 📑 Job Listing | jobs |
| 🔄 Process Synchronization | waitpid() |
| 🔧 File Descriptor Handling | dup2(), close() |
The shell continuously performs the following operations:
Read → Parse → Identify → Execute → Manage Process → Return to Prompt
┌──────────────────┐
│ Start Shell │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Read User Input │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Parse Command │
└────────┬─────────┘
│
┌──────────┴──────────┐
▼ ▼
┌──────────────┐ ┌────────────────┐
│ Built-in │ │ External │
│ Command │ │ Command │
└──────┬───────┘ └───────┬────────┘
│ │
▼ ▼
Execute Directly fork() → execvp()
│
▼
┌────────────┐
│ pipe()? │
└─────┬──────┘
│
┌─────┴─────┐
│ │
YES NO
│ │
▼ ▼
N-Level Execute
Pipeline Normally
│
└─────┬─────┘
▼
waitpid()
│
▼
Return Prompt