Pipex is a program that simulates the shell's pipe behavior. It handles command execution, file redirection, and implements features like here_doc and multiple pipes. The project aims to deepen understanding of Unix processes, file descriptors, and pipe mechanisms.
- Completion Date: 10/01/2025
- Grade: 125/100 ✨
- Basic pipe functionality (
cmd1 | cmd2) - Multiple commands support
- Here_doc implementation (
<<) - Error handling
- Memory management
- Path resolution for commands
git clone <repository_url>
cd pipex
make # For mandatory part
make bonus # For bonus features./pipex infile cmd1 cmd2 outfileThis is equivalent to: < infile cmd1 | cmd2 > outfile in shell
./pipex infile cmd1 cmd2 cmd3 ... cmdn outfileThis is equivalent to: < infile cmd1 | cmd2 | cmd3 ... | cmdn > outfile
./pipex here_doc LIMITER cmd1 cmd2 outfileThis is equivalent to: << LIMITER cmd1 | cmd2 >> outfile
pipex.c: Main program implementationinit_pipex.c: Initialization functionsexec_cmds.c: Command execution logicparse_cmds.c: Command parsing and path resolutionparse_args.c: Argument parsingexit.c: Cleanup and exit handling
pipex_bonus.c: Extended main programexec_cmds_bonus.c: Multiple command executionheredoc_bonus.c: Here_doc implementationinit_pipex_bonus.c: Enhanced initialization- Other bonus variants of core files
pipex.h: Main header filepipex_bonus.h: Bonus features header
- Process Creation: Uses
fork()to create child processes - Pipe Communication: Implements pipe mechanism for inter-process communication
- File Handling: Manages file descriptors for input/output redirection
- Command Resolution: Searches system PATH for command executables
- Memory Management: Proper allocation and deallocation of resources
typedef struct s_pipex
{
int in_fd; // Input file descriptor
int out_fd; // Output file descriptor
int *pipefd; // Pipe file descriptors
pid_t *pids; // Process IDs
int child_id; // Current child process ID
char **envp; // Environment variables
char **cmd_path; // Command paths
char ***cmd_args; // Command arguments
int cmd_nb; // Number of commands
bool heredoc; // Here_doc flag
} t_pipex;- File access permissions
- Command existence and execution rights
- Memory allocation failures
- Pipe creation errors
- Fork failures
- Invalid number of arguments
- All allocated memory is properly freed
- File descriptors are properly closed
- Temporary files (here_doc) are cleaned up
- Handles both success and failure cases
The program has been tested with various scenarios:
- Basic pipe operations
- Multiple commands
- Here_doc functionality
- Invalid commands
- Missing files
- Permission issues
- Memory leaks (using Valgrind)
- The program follows 42 School's coding standards (Norminette)
- Error messages are displayed on standard error
- The program handles environment variables properly
- Command paths are resolved dynamically
- Supports both relative and absolute paths for commands
This project is developed at 42 School and follows its guidelines. Usage and redistribution are permitted under the school's terms.
Author: macuesta Last Updated: 12/01/2025