Welcome to Pipex, a foundational project in the 42 School curriculum designed to deepen understanding of Unix pipe mechanics, process creation, and inter-process communication through the use of C programming. This implementation adheres strictly to the 42 Norm and project specifications, featuring modular code, centralized error handling, and a clean structure to ensure maintainability.
- Introduction
- Project Structure
- Key Features
- Technologies Used
- Installation
- Usage
- Error Handling and Exit Codes
- Contributing
- Ac 8000 knowledgements
- Author
Pipex emulates Unix shell behavior for piping commands, allowing you to execute:
< infile cmd1 | cmd2 > outfile
The program demonstrates:
- Process management using
fork
. - Pipe redirection with
dup2
. - File I/O operations with
open
,close
, and system calls. - Handling complex edge cases (e.g., missing files, invalid commands).
This project lays a strong foundation for more advanced projects like Minishell and Philosophers.
.
βββ include/ # Header files
β βββ pipex.h # Centralized function declarations and macros
βββ libft/ # Enhanced Libft with additional utilities
β βββ include/ # Header files for libft
β βββ src/ # Source files for libft
βββ src/ # Pipex implementation files
β βββ cmd/ # Command execution logic
β βββ core/ # Core application logic
β βββ error/ # Centralized error handling
β βββ file/ # File and pipe management
β βββ utils/ # Utility functions for memory/resource cleanup
βββ Makefile # Automates compilation
βββ README.md # Documentation (this file)
- Functions grouped by responsibilities for better organization and reusability:
- cmd/: Command path resolution and execution (
exec_cmd
,get_cmd_path
). - core/: Application entry point (
pipex.c
). - error/: Unified error handling (
free_resources_on_error
). - file/: File and pipe operations (
open_files
,create_pipe
). - utils/: Resource cleanup utilities (
free_2d_array
,free_pipex
).
- cmd/: Command path resolution and execution (
- Errors are processed through a single entry point, ensuring proper cleanup and detailed error messages. Exit codes conform to Unix standards:
127
: Command not found.126
: Permission denied.1
: Generic error.
- Documentation for each function following 42 Norm, making the project beginner-friendly and easy to extend.
- C Programming: Core implementation.
- Libft Library: Extended functionality with
ft_printf
and utilities. - Makefile: For efficient compilation.
- GCC Compiler: Compilation with strict warnings and memory debugging enabled.
git clone https://github.com/kitearuba/pipex.git
cd pipex
Run:
make
To emulate:
< infile cmd1 | cmd2 > outfile
Run:
./pipex infile "cmd1" "cmd2" outfile
127
: Command not found or invalid path.126
: Permission denied for the command.1
: Other errors (e.g., failed file open).
-
Missing Input File:
./pipex nonexistent.txt "ls" "wc" output.txt
Output:
pipex: Unable to open input file: No such file or directory
-
Invalid Command:
./pipex infile "invalidcmd" "wc" outfile
Output:
pipex: invalidcmd: command not found
Suggestions and improvements are always welcome! Feel free to fork the repository and submit a pull request.
Special thanks to the 42 Network community for providing a collaborative learning environment and valuable feedback.
- chrrodri
GitHub Profile