Skip to content

"This project will allow you to explore a UNIX mechanism in detail, one that you are already familiar with, by implementing it in your program."

Notifications You must be signed in to change notification settings

Patthh/42_pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42 Pipex

██████╗░██╗██████╗░███████╗██╗░░██╗
██╔══██╗██║██╔══██╗██╔════╝╚██╗██╔╝
██████╔╝██║██████╔╝█████╗░░░╚███╔╝░
██╔═══╝░██║██╔═══╝░██╔══╝░░░██╔██╗░
██║░░░░░██║██║░░░░░███████╗██╔╝╚██╗
╚═╝░░░░░╚═╝╚═╝░░░░░╚══════╝╚═╝░░╚═╝

📖 What is pipex 📊?

A program that simulates the Unix pipe mechanism

        Pipex is a project associated with the curriculum of École 42, a coding school known for its project-based learning approach. The Pipex project uses the C programming language to recreate the behavior of the shell pipe operator `|` along with file redirections. The goal of this project is to teach students about Unix processes, file descriptors, pipes, and inter-process communication while deepening their understanding of how shell commands are executed.

✅ Status

Project completion status

Completed on : 2024-04-30
100/100

🚀 Usage

To clone and compile:

git clone https://github.com/Patthh/42_pipex.git
cd 42_pipex && make

To run the program:

./pipex infile cmd1 cmd2 outfile

For example:

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

This is equivalent to: < input.txt grep hello | wc -l > output.txt in shell

✨ Features

  • 🔄 Handles multiple pipes and commands
  • 📂 Properly manages file descriptors to avoid leaks
  • 🔍 Robust error handling and informative error messages
  • 🚀 Efficient process creation and management
  • 🛠️ Support for commands with arguments and options
  • 🔎 PATH environment variable parsing
  • 📝 Clean code following the 42 Norm

Warning

Improper handling of file descriptors may result in memory leaks or zombie processes

🛠️ Implementation Details

Core Components

The Pipex program consists of these main components:

Component Description
📂 File Handling Opening input/output files with proper permissions
🔄 Pipe Creation Creating pipes for inter-process communication
🐣 Process Forking Creating child processes with fork()
⚙️ Command Execution Parsing and executing commands with execve()
🔍 Path Resolution Finding the correct binary path for commands
🧹 Resource Cleanup Proper closing of file descriptors and memory management

Note

"Connecting processes like plumbing - one pipe at a time"

Pipe System
A journey into Unix process communication



Made with ❤️ and lots of 📊

About

"This project will allow you to explore a UNIX mechanism in detail, one that you are already familiar with, by implementing it in your program."

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published