myshell is a lightweight Unix-style command-line shell implemented in C.
The project is focused on core operating system concepts such as process creation, inter-process communication, file descriptor manipulation, and concurrent execution using low-level system calls.
It demonstrates how a basic shell operates internally at the system level.
- Execute external programs using
fork()andexecvp() - Input redirection (
<) - Output redirection (
>) - Pipe support (
|) - Background execution (
&) - Built-in
cdcommand - Synchronization using
wait()
The shell is built using standard Unix system calls:
fork()— Creates child processesexecvp()— Executes external commandspipe()— Enables communication between processesdup2()— Redirects standard input and outputwait()— Synchronizes parent and child processeschdir()— Changes the working directory
Commands are divided into arguments using strtok().
Redirection is handled in the child process before executing commands.
Compile the project using:
makeOr manually:gcc -Wall -Wextra -std=c11 -g src/myshell.c -o myshell
Start the shell with:
./myshell
You will see the prompt:
myshell>
- Basic execution ——
ls - Pipe ——
ls | wc - Output redirection ——
echo hello > output.txt - Input redirection -—
sort < input.txt - Background execution -—
sleep 5 & - Built-in command -—
cd src
This project was created to strengthen understanding of Unix process management and systems programming in C.
It is able to demonstrate practical use of operating system primitives to build a functional command shell.