Skip to content

Latest commit

 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project has been created as part of the 42 curriculum by aalemami.

pipex


Description

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.


Instructions

Compilation

Compile using make:

make

Additional rules:

make clean   # Remove object files
make fclean  # Remove object files and executable
make re      # Rebuild from scratch

Usage

./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

Examples

./pipex infile "ls -l" "wc -l" outfile
./pipex infile "cat" "grep hello" outfile
./pipex infile "head -5" "tr a-z A-Z" outfile

Resources

AI Usage

AI was used as a learning and reference tool for:

  • Understanding file descriptor duplication mechanics with dup2().
  • Clarifying process execution workflows with execve() and environment PATH parsing.
  • Debugging exit status propagation and zombie process prevention via waitpid().

About

A UNIX mechanism simulator in C that replicates shell pipe routing (< file1 cmd1 | cmd2 > file2) using pipe(), fork(), and execve().

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages