This project has been created as part of the 42 curriculum by chguerr.
pipex is a C program that reproduces the behavior of the Unix shell pipe operator |.
It mimics the following shell command:
< file1 cmd1 | cmd2 > file2The program reads from file1, executes cmd1 with that input, passes its output to cmd2 through a pipe, and writes the final result to file2.
The goal is to understand how Unix processes communicate with each other using pipes, file descriptors, and system calls such as fork, execve, and dup2.
makeTo recompile from scratch:
make reTo remove object files:
make cleanTo remove all generated files including the binary:
make fclean./pipex file1 "cmd1" "cmd2" file2./pipex input.txt "cat" "grep hello" output.txt
./pipex input.txt "ls -l" "wc -l" output.txt
./pipex input.txt "cat" "tr a-z A-Z" output.txtEach example is equivalent to running the corresponding shell pipeline:
< input.txt cat | grep hello > output.txtfile1does not exist or has no read permission → error message and exitfile2cannot be created or written → error message and exit- Command not found →
pipex: command not found: <cmd>and exit with code 127
- Linux man page — pipe(2)
- Linux man page — fork(2)
- Linux man page — execve(2)
- Linux man page — dup2(2)
- Linux man page — waitpid(2)
- File descriptors explained — GNU libc
Claude (claude.ai) was used as a learning assistant throughout this project. It was used for:
- Explaining concepts such as
fork,execve,dup2,pipe, andwaitpidwith pseudocode and C examples - Identifying bugs in the code (undeclared variables, double free, wrong
open()syntax) - Answering questions about the 42 Norm (variable limits, function parameter limits)
- Reviewing code after each correction without writing the code directly
All code was written by the student. AI was used exclusively for explanation and review.