A mini Unix shell implemented in C demonstrating process control, signal handling, and interaction with the Linux /proc filesystem. Developed for CS 392 Systems Programming.
Minishell is a custom command-line interpreter built from scratch in C. The project showcases low-level systems programming techniques including subprocess creation, directory and filesystem traversal, manual parsing, resource management, and signal-safe I/O.
The repository includes a compiled executable (minishell) as well as the full source implementation.
| Command | Description |
|---|---|
cd, cd <path> |
Changes the working directory; supports home directory (~), absolute, and relative paths. |
pwd |
Prints the full current working directory. |
lf |
Lists non-hidden files in the current directory. |
lp |
Enumerates active system processes by scanning the /proc filesystem. |
exit |
Frees allocated resources and exits the shell. |
If a command is not a built-in, the shell delegates execution to the OS using:
fork()to spawn a child processexecvp()to replace the child process imagewait()to synchronize with the parent
Supports variable-length argument lists up to 50 tokens.
lp replicates a simplified version of top by reading from /proc/[pid]/:
- Extracts PID from directory names
- Reads the program’s command line from
cmdline - Retrieves the associated user from system password entries
- Stores results in an array of process structs
- Sorts the list numerically by PID
This demonstrates direct interaction with the Linux /proc virtual filesystem and parsing of kernel-generated process information.
Minishell implements a custom handler for SIGINT (Ctrl+C):
- Foreground child processes receive the interrupt
- The shell itself remains active
- Interruptions during
getline()are detected through avolatile sig_atomic_tflag
gcc minishell.c -o minishell
./minishell