PIP is a lightweight implementation of Unix-style pipelines. It executes commands, redirects their input/output, and connects them using pipes—mimicking the behavior of:
< infile cmd1 | cmd2 | cmd3 > outfileIt is written entirely in C using low-level system calls, with no reliance on external utilities beyond what a POSIX system already provides.
PIP is a minimal command pipeline executor. Its purpose is to provide a small, readable, dependency-free implementation of:
- Process creation
fork - Inter-process communication
pipe - Standard stream redirection
dup2 - Command execution
execve - Error propagation & file handling
It aims to act as a reference for developers who want to understand how shells execute pipelines internally.
- ✅ Environment-aware command resolution (PATH lookup)
- ✅ Clean process management and error handling
Mandatory part:
- ✅ Execute two commands chained via pipes
- ✅ Redirect input/output from files (
<or>)
Bonus part:
- ⭐ Support for here-documents (
<<) - ⭐ Support for append-mode (
>>)
Click to expand
Pip/
├── mandatory/ # Character classification
│ ├── main.c
│ ├── pipe.c
│ ├── utils.c
│ └── pipe.h
│
├── bonus/ # File descriptor I/O utilities
│ ├── main_bonus.c
│ ├── pipe_bonus.c
│ ├── utils_bonus.c
│ └── pipe_bonus.h
|
├── README.md
├── Makefile
├── libft.h
└── libft.a
- Clone the repository
git clone https://github.com/Sfeso13/pip.git
cd pip- Compile the library
make # for mandatory part
make bonus # for bonus partThis creates a runnable program called pipex/pipex_bonus.
- Clean compiled objects
make clean # remove object files
make fclean # remove object files and library
make re # rebuild everythingMandatory part:
In this part the program takes 4 arguments: input file, command1 to run, commad2 to run, outfile:
./pipex infile "cmd1" "cmd2" outfileequivalent to:
< infile cmd1 | cmd2 > outfileexample:
./pipex infile cat "wc -l" outfileBonus part:
- In this bonus part, the program support multiple piped commands (as long as the first and last argument are, respectively, the input and output file):
example:
./pipex_bonus infile cmd1 cmd2 cmd3 cmd4 cmd5 outfileequivalent to:
cmd1 < infile | cmd2 | cmd3 | cmd4 | cmd5 > outfile- It also supports the here_doc and append mode, by specifying here_doc as the first argument
example:
./pipex_bonus here_doc LIMITER cmd1 cmd2 outfileequivalent to:
cmd1 << LIMITER | cmd2 >> outfile