A simple shell implementation in C that reads and executes commands from user input. This shell supports basic command execution, signal handling, and built-in commands like cd
and exit
.
- Execute External Commands: Run any system command (like
ls
,pwd
, etc.). - Built-in Commands:
cd
- Change the current directory.exit
- Exit the shell.
- Signal Handling:
- Handle
Ctrl+C
gracefully without exiting the shell.
- Handle
To compile and run this project, you'll need:
- GCC or any C compiler.
- A Unix-like environment (Linux, macOS, etc.).
Clone the repository and compile the minishell.c
file using GCC:
git clone https://github.com/iNoles/Mini-Shell.git
cd Mini-Shell
gcc -o minishell minishell.c
After compiling, run the shell with:
./minishell
- Press Ctrl+C to interrupt a running command or get back to the shell prompt.
- To exit the shell, use the exit command.
This project showcases your understanding of:
- System Programming: Managing low-level operations like input/output, memory allocation, and signal handling using C standard libraries.
- Process Management: Creating and managing child processes using fork(), executing commands with execvp(), and synchronizing with waitpid().
- Inter-process Communication: Handling signals, like SIGINT for Ctrl+C, to communicate between user and shell processes gracefully.
This shell program dynamically allocates memory for user input and parsed arguments. All allocated memory is properly freed to prevent memory leaks.
Contributions, issues, and feature requests are welcome! Feel free to check out the issues page if you have any questions or suggestions.
- Fork the project.
- Create your feature branch:
git checkout -b feature/YourFeature
. - Commit your changes:
git commit -m 'Add YourFeature'
. - Push to the branch:
git push origin feature/YourFeature
. - Open a pull request.