This project has been created as part of the 42 curriculum by aalemami.
pipex is a Unix process management project that replicates the behavior of the shell pipe operator. It takes an input file, two commands, and an output file, chaining them together exactly as the shell does with < and > redirections and |.
The goal is to understand how processes communicate through pipes using fork(), pipe(), dup2(), and execve(), and to properly handle file descriptors, child process synchronization, PATH resolution, and resource cleanup.
Compile using make:
makeAdditional rules:
make clean # Remove object files
make fclean # Remove object files and executable
make re # Rebuild from scratch./pipex <infile> <cmd1> <cmd2> <outfile>| Argument | Description |
|---|---|
infile |
File to read input from |
cmd1 |
First command (reads from infile) |
cmd2 |
Second command (writes to outfile) |
outfile |
File to write final output to |
Equivalent shell behavior:
< infile cmd1 | cmd2 > outfile./pipex infile "ls -l" "wc -l" outfile
./pipex infile "cat" "grep hello" outfile
./pipex infile "head -5" "tr a-z A-Z" outfile- pipe(2) — Linux man page
- fork(2) — Linux man page
- execve(2) — Linux man page
- dup2(2) — Linux man page
- Unix Processes in C — CodeVault
AI was used as a learning and reference tool for:
- Understanding file descriptor duplication mechanics with
dup2(). - Clarifying process execution workflows with
execve()and environmentPATHparsing. - Debugging exit status propagation and zombie process prevention via
waitpid().