Skip to content

This project is the discovery in detail and by programming of a UNIX mechanism that you already know.

Notifications You must be signed in to change notification settings

ArthurBeznik/42_codam_pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42_codam_pipex

This project is the discovery in detail and by programming of a UNIX mechanism that you already know: pipes.

Usage

The pipex program will be executed as follows:

./pipex file1 cmd1 cmd2 file2

It must take 4 arguments:

• file1 and file2 are file names.

• cmd1 and cmd2 are shell commands with their parameters.

It must behave exactly the same as the shell command below:

$> < file1 cmd1 | cmd2 > file2

Constraints

Functions allowed: open, close, read, write, malloc, free, perror, strerror, access, dup, dup2, execve, exit, fork, pipe, unlink, wait, waitpid.

Return value

The return value of pipex should be the exit code of the second command.

Flowchart

Overview

Screen Shot 2022-04-12 at 11 03 35 AM

Input parsing

Screen Shot 2022-04-12 at 11 04 20 AM

Child process 1 & 2

Screen Shot 2022-04-12 at 11 05 03 AM

Screen Shot 2022-04-12 at 11 05 24 AM

Command execution

Screen Shot 2022-04-12 at 11 05 43 AM

Parent process

Screen Shot 2022-04-12 at 11 05 59 AM

Examples

a.

./pipex infile "ls -l" "wc -l" outfile

Should behave like:

< infile ls -l | wc -l > outfile

b.

./pipex infile "grep a1" "wc -w" outfile

Should behave like:

< infile grep a1 | wc -w > outfile

About

This project is the discovery in detail and by programming of a UNIX mechanism that you already know.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published