Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ› οΈ Pipex πŸ”—

Welcome to my Pipex project! πŸš€

Crafted as part of the 42 Madrid journey, this project is all about mastering the art of pipes, redirections, and process management


🌟 Overview

Pipex is a C program that mimics the behavior of shell pipes (|). It takes an input file, executes a series of commands, and writes the final output to an output file, chaining commands with pipes just like in a real shell. Think of it as a mini-shell that handles cmd1 | cmd2 while managing file descriptors with finesse. πŸ’‘


βš™οΈ How It Works

Here’s the magic behind my implementation:

Component What It Does
πŸ–₯️ Parser Reads and validates input arguments and commands.
πŸ”— Pipe Master Creates pipes and sets up communication between processes.
πŸ› οΈ Process Wizard Forks processes to execute each command independently.
πŸ“‚ FD Manager Redirects input/output using dup2 for seamless flow.
πŸ›‘οΈ Error Guardian Handles errors like missing commands or file issues.

πŸ—ΊοΈ Roadmap

πŸ”Ή [START!] --> [Parse Args] --> [Open Files] --> [Create Pipe] --> [Fork & Execute] --> [Redirect I/O] --> [Repeat for Cmd2] --> [Write to File] πŸ”Ή

  • Step 1: Parse the arguments to extract commands, input, and output files. πŸ“œ
  • Step 2: Open the input and output files with proper error handling. πŸ“‚
  • Step 3: Create a pipe to connect the two commands. πŸ”—
  • Step 4: Fork processes to execute each command, redirecting I/O with dup2. πŸ› οΈ
  • Step 5: Execute the commands using execve, passing the output of the first to the second. ⚑
  • Step 6: Write the final result to the output file and clean up. βœ…

πŸ“‚ Example Flow

  • Input Command: ./pipex file1 "ls -l" "wc -l" file2 πŸ–₯️
  • Input File (file1): (empty or with content, doesn’t matter for this example) πŸ“„
  • Cmd1 Output: dir file1 file2 pipex πŸ“‹
  • Cmd2 Output: 4 πŸ”’
  • Output File (file2): 4 πŸ’Ύ

✨ Built with πŸ’» and β˜• at 42 Madrid ✨

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages