Skip to content

pipex is a 42 School project that replicates Unix piping behavior by executing chained commands using fork, execve, pipe, and file redirection. It demonstrates process control and inter-process communication in C.

Notifications You must be signed in to change notification settings

ayeshamk23/pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— pipex

A Unix pipe emulator using fork, execve, and pipe.

πŸ“Œ Description

pipex is a 42 School project that recreates shell-like piping between commands. It simulates the behavior of:

< file1 cmd1 | cmd2 > file2

The program replicates this using system-level calls like fork, execve, pipe, and file I/O redirection. It helps build a deep understanding of Unix internals, process management, and inter-process communication.

βš™οΈ Features

  • Executes two commands connected via a pipe
  • Supports input/output file redirection
  • Uses only low-level system calls (no popen or system())
  • Handles error reporting and command path resolution

πŸš€ Usage

./pipex infile "cmd1" "cmd2" outfile

πŸ’‘ Example

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

Which behaves like:

< input.txt grep hello | wc -l > output.txt

πŸ”§ Requirements

  • Only allowed to use:
    open, close, read, write, malloc, free, access, dup, dup2, execve, exit, fork, pipe, unlink, wait, waitpid, perror, strerror
  • No system() or popen() calls

πŸ“˜ Concepts Learned

  • 🧡 Inter-Process Communication (IPC) using pipes
  • 🧬 Process management: creating child processes with fork()
  • πŸšͺ File descriptor redirection using dup2()
  • 🧠 Command execution with execve() and path resolution
  • πŸ—‚οΈ File I/O operations (open, read, write, close)
  • πŸ”„ Error handling and custom message reporting
  • πŸ“‚ Environment parsing and working with PATH
  • ♻️ Memory management and resource cleanup
  • βš™οΈ Debugging complex flows involving multiple processes

About

pipex is a 42 School project that replicates Unix piping behavior by executing chained commands using fork, execve, pipe, and file redirection. It demonstrates process control and inter-process communication in C.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published