Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 1.36 KB

README.md

File metadata and controls

46 lines (37 loc) · 1.36 KB

Pipex

fract-ol_badge/

Reproduction of shell pipes


Final score

fractol_grade/

About pipex_pipe/

Pipex is a C project that simulates the behavior of the shell when piping the output of one command to the input of another using the | operator. The project involves using system calls like fork(), pipe(), dup2(), and execve() to create a pipeline between two processes, enabling them to communicate by passing data from one command to another, just as you would in a Unix-like shell.

# ./pipex infile cmd1 cmd2 outfile
pipe()
 |
 |-- fork()
      |
      |-- child // cmd1
      :     |--dup2()
      :     |--close end[0]
      :     |--execve(cmd1)
      :
      |-- parent // cmd2
            |--dup2()
            |--close end[1]
            |--execve(cmd2)
 
# pipe() sends the output of the first execve() as input to the second execve()
# fork() runs two processes (i.e. two commands) in one single program
# dup2() swaps our files with stdin and stdout