Skip to content

A project about inter-process communication using pipes, recreating shell pipelines. Topics

Notifications You must be signed in to change notification settings

Cursedzyko/pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pipex

Description

This project aims to deepen your understanding of the two concepts that you already know: Redirections and Pipes. It is an introductory project for the bigger UNIX projects that will appear later on in the cursus.

Skills

  • Unix
  • Imperative programming

Idea

The general idea: we read from infile, execute cmd1 with infile as input, send the output to cmd2, which will write to outfile. 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.

// each cmd needs a stdin (input) and returns an output (to stdout)

infile                                             outfile
as stdin for cmd1                                 as stdout for cmd2            
       |                        PIPE                        ↑
       |           |---------------------------|            |
       ↓             |                       |              |
      cmd1   -->    end[1]       ↔       end[0]   -->     cmd2           
                     |                       |
            cmd1   |---------------------------|  end[0]
           output                             reads end[1]
         is written                          and sends cmd1
          to end[1]                          output to cmd2
       (end[1] becomes                      (end[0] becomes 
        cmd1 stdout)                           cmd2 stdin)

About

A project about inter-process communication using pipes, recreating shell pipelines. Topics

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published