Skip to content

annafenzl/42-pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42-pipex

Unix System Programming and Pipelines: A Pipex Project Overview

This is a project for 42Heilbronn school's curriculum.

The goal of the project is to write a program that will implement the behavior of the shell | and redirections.

Description

mandatory part:

run make

The program behaves exactly the same as this shell command:

$> < file1 cmd1 | cmd2 > file2

The program will be executed as follows:

./pipex file1 cmd1 cmd2 file2

  • file1: the name of the input file
  • cmd1: the first shell command to be executed with its parameters
  • cmd2: the second shell command to be executed with its parameters
  • file2: the name of the output file

e.g: $> ./pipex infile "ls -l" "wc -l" outfile should behave like: < infile ls -l | wc -l > outfile

bonus part:

run make bonus

  • Handling multiple pipes:

./pipex file1 cmd1 cmd2 cmd3 ... cmdn file2 should behave like < file1 cmd1 | cmd2 | cmd3 ... | cmdn > file2.

  • Supporting << and >> when the first parameter is "here_doc":

./pipex here_doc LIMITER cmd cmd1 ... cmdn file should behave like cmd << LIMITER | cmd1 ... | cmdn >> file.

What i learned:

  • how to use pipes to redirect input and output between multiple processes.
  • how to check for unclosed pipes using the lsof command.
  • how to use the fork() function to create child processes.
  • how to use the execve() function to execute shell commands in child processes.
  • how to use file descriptors, such as dup() and dup2(), to redirect input and output between processes.
  • how to handle errors and manage memory to avoid issues like memory leaks and unexpected program termination.
  • Bonus: Handling multiple pipes and supporting << and >> for "here_doc" input.

These concepts are fundamental to Unix system programming and pipelines, and are widely used in various applications, such as data processing and networking.

About

Shell pipes and redirections

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published