Advanced Systems Programming
Paris 8 University (Bachelor Legacy) 2019 Original Development
2026 Refactored for Translation.
MyShelf is a functional Unix-like shell developed in C. It was created as the final project for the Operating Systems course at Paris 8 University. It implements the core mechanics of a command-line interpreter, focusing on process lifecycle management, environment handling, and I/O stream manipulation.
Starting from a foundational academic version, this 2026 edition focuses on code translation.
- cd [path]: Manual implementation of directory navigation.
- Supports relative and absolute paths with call of chdir().
- Handles special symbols: . (current), .. (parent), and ~ (home).
- Includes a security check to prevent navigating above the /home directory.
- exit: Gracefully terminates the shell session.
- Execution: Launches external binaries using fork(), execv(), and wait().
- Background Tasks (&): Supports non-blocking process execution.
- Displays the Process ID (PID) upon launch.
- Monitors child processes to provide termination notifications and prevent zombie processes (usingwaitpidlogic).
- PATH Resolution: Automatically searches for executables within the directories defined in the system's PATH environment variable.
- Redirections: Implements standard input (<) and output (>) redirection to files using dup2 and fcntl logic.
- Pipes (|): Supports sequential command chaining where the output of one process is piped as the input to the next.
- File Auto-completion: Advanced implementation allowing users to complete filenames using the Tab key, integrated within the terminal read logic.
The shell follows a modular REPL (Read-Eval-Print Loop) design:
- Lexer/Parser: A custom decouper function tokenizes the input string based on delimiters (spaces, tabs, newlines)
- String Manipulation: Specific internal functions like cutstr and selectstr are used for complex parsing of command arguments.
- System Headers: Uses a dedicated sys.h to manage critical includes like unistd.h, sys/wait.h, and sys/stat.h.
- Executor: Handles the logic of
forking, searching thePATH, and executing system calls.
- Process Monitor: A core routine that monitors background tasks (
&) and ensures terminated child processes are properly reaped to prevent system resource exhaustion (zombie processes).
- Memory Management: Fixed specific memory leaks (e.g., in the stat buffer and string duplications) to ensure stability.
- Language Translation: All internal code comments and user-facing messages have been translated from French to English.
Bash
git clone https://github.com/your-repo/myshelf.git
cd myshelf
make
./myshelf