Skip to content

Repository files navigation

🐚 MiniShell — Custom Unix Shell in C

📌 Overview

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.


✨ Key Features

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()

🧠 How MiniShell Works

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

About

A Unix-based Mini Shell implemented in C with built-in commands, external command execution, n-way piping, process management, and signal handling using Linux system calls.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages