Mini Shell en CMini Shell in C
TechnologiesTechnologies (6)
Implémentation d'un mini shell en C — gestion des pipes, redirections, exécution en arrière-plan et builtins (cd, pwd, exit). Projet de cours systèmes d'information.Mini shell implemented in C — pipes, redirections, background execution and builtins (cd, pwd, exit). Systems programming course project.
Lire la présentation complèteRead the full introduction
Implémentation d'un mini shell en C — gestion des pipes, redirections, exécution en arrière-plan et builtins (cd, pwd, exit). Projet de cours systèmes d'information.Mini shell implemented in C — pipes, redirections, background execution and builtins (cd, pwd, exit). Systems programming course project.
Projet de cours en systèmes d'information — implémentation d'un mini shell en C capable de lire et exécuter des commandes avec les fonctionnalités essentielles d'un vrai shell Unix.
Fonctionnalités implémentées
- Pipe (
|) : fork double avecpipe()etdup2pour connecter lestdoutde la commande 1 austdinde la commande 2. - Redirection (
>) : fork +open()+dup2sur stdout vers un fichier. - Arrière-plan (
&) : exécution sans attendre la fin du processus enfant. - Séquences (
;) : découpage et exécution de plusieurs commandes en série. - Builtins :
cdexécuté dans le parent (nécessaire pour changer le répertoire courant),pwd,exit.
Gestion mémoire
Chaque token est dupliqué avec strdup et libéré après usage. La séparation entre analyse (parse_input), orchestration (execution_cmd) et exécution (executefork) évite les doubles libérations.
Piste d'amélioration : gérer plusieurs pipes chaînés (cmd1 | cmd2 | cmd3).
Systems programming course project — implementation of a mini shell in C capable of reading and executing commands with the core features of a real Unix shell.
Implemented features
- Pipe (
|) : double fork withpipe()anddup2to connect stdout of command 1 to stdin of command 2. - Redirection (
>) : fork +open()+dup2on stdout to a file. - Background (
&) : execution without waiting for the child process to finish. - Sequences (
;) : split and run multiple commands in series. - Builtins :
cdruns in the parent process (required to actually change the working directory),pwd,exit.
Memory management
Each token is duplicated with strdup and freed after use. Separation between parsing (parse_input), orchestration (execution_cmd) and execution (executefork) prevents double-free issues.
Improvement path: handle multiple chained pipes (cmd1 | cmd2 | cmd3).