Skip to content

A C program that mimics shell pipelines, allowing multiple commands to be executed with redirected input/output. Pipex handles file descriptors, child processes, and command execution, demonstrating mastery of Unix system calls and inter-process communication in a minimal, efficient shell-like environment.

Notifications You must be signed in to change notification settings

Felipp3san/42-pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pipex

A Unix command-line tool built in C, designed to replicate shell pipelines and reinforce understanding of process management, file descriptors, and inter-process communication. Pipex allows executing commands with redirected input and output, mimicking basic Bash pipeline behavior.

Features (Mandatory)

  • Command execution with exactly 2 commands
  • Input/output redirection (< and >)
  • Pipeline connecting the two commands
  • Error handling consistent with shell behavior
  • Memory-safe execution with no leaks

Features (Bonus)

  • Support for multiple commands in a pipeline
  • Here-documents (<<) support
  • Enhanced error handling for edge cases
  • Dynamic number of commands in the pipeline

Tech Stack

  • C – Core language
  • POSIX system callsfork, execve, pipe, dup2, wait etc.
  • Makefile – For easy build and management

Installation

  1. Clone the repository:
git clone https://github.com/Felipp3san/42-pipex
cd 42-pipex
  1. Compile the project:
make          # Compile mandatory version
make bonus    # Compile bonus version
  1. Run the executable:
./pipex file1 cmd1 cmd2 file2        # Mandatory
./pipex file1 cmd1 cmd2 ... cmdn file2  # Bonus

Usage

  • Mandatory (2 commands only):
./pipex infile "grep hello" "wc -l" outfile

This executes grep hello < infile | wc -l > outfile.

  • Bonus (multiple commands):
./pipex input.txt "cat" "grep data" "sort" output.txt
  • Bonus: Here-document:
./pipex here_doc LIMITER "cat" "wc -l" outfile

Allows input until LIMITER is reached.

Compilation

  • Build the mandatory executable:
make
  • Build the bonus executable:
make bonus
  • Remove object files:
make clean
  • Remove all binaries and rebuild:
make re

License

Educational project under 42 School academic policy.

About

A C program that mimics shell pipelines, allowing multiple commands to be executed with redirected input/output. Pipex handles file descriptors, child processes, and command execution, demonstrating mastery of Unix system calls and inter-process communication in a minimal, efficient shell-like environment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published