Skip to content
/ pipex Public

A simplified shell-like pipe mechanism in C. This project replicates the shell behavior of piping commands and builds understanding of processes, pipes, file descriptors, and execve.

Notifications You must be signed in to change notification settings

Aztaban/pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PIPEX

This project is a simplified implementation of shell pipelines. It mimics the shell's ability to pipe commands using the | operator. The program handles input/output redirection and command execution using fork(), execve(), and pipe() system calls.


πŸ›  Usage

./pipex infile "cmd1" "cmd2" outfile

Equivalent to:

< infile cmd1 | cmd2 > outfile

βœ… Example

./pipex input.txt "grep hello" "wc -l" output.txt

This reads from input.txt, runs grep hello, pipes the result into wc -l, and writes the output to output.txt.


πŸ”§ Bonus Features

./pipex here_doc LIMITER cmd1 cmd2 ... cmdN outfile

Supports:

  • Multiple commands (cmd1 | cmd2 | ... | cmdN)
  • here_doc functionality: reads input from stdin until the given LIMITER.
  • Appends to the output file if here_doc is used.

Bonus Example

./pipex here_doc END "cat" "grep hello" "wc -l" output.txt

πŸ“‚ File Structure

β”œβ”€β”€ include/
β”‚   β”œβ”€β”€ pipex.h              # Header file for mandatory part
β”‚   └── pipex_bonus.h        # Header for bonus features
β”œβ”€β”€ libft/                   # Libft library
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.c               # Entry point for mandatory part
β”‚   β”œβ”€β”€ process.c            # Process execution (mandatory)
β”‚   β”œβ”€β”€ pathfinder.c         # PATH resolution for commands
β”‚   β”œβ”€β”€ helpers.c            # Common error/child handlers
β”œβ”€β”€ src_bonus/
β”‚   β”œβ”€β”€ main_bonus.c         # Entry for bonus (multi-pipe, here_doc)
β”‚   β”œβ”€β”€ process_bonus.c      # Process handling with multiple pipes
β”‚   β”œβ”€β”€ pathfinder.c         # PATH resolution for commands
β”‚   β”œβ”€β”€ helpers.c            # Common error/child handlers
β”œβ”€β”€ Makefile                 # Builds the project and handles rules
└── README.md                # You're reading it!

πŸ› οΈ Compilation

To build the project, run:

make              # Builds the mandatory version
make bonus        # Builds the bonus version
make clean        # Removes object files
make fclean       # Removes all binaries and objects
make re           # Rebuilds everything

πŸ‘€ Author

Created and maintained by Martin Justa as part of the 42 school curriculum.

About

A simplified shell-like pipe mechanism in C. This project replicates the shell behavior of piping commands and builds understanding of processes, pipes, file descriptors, and execve.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published