The aim of this project is to start working with Unix processes.
In this project, we have to reproduce Bash's pipe operator (|
), whose effect is to redirect a commands output to be the input of another command.
After running make
in the project's directory, you can run commands that have the following form:
./pipex input.txt cmd1 cmd2 output.txt
is equivalent to Bash's:
< input.txt cmd1 | cmd2 > output.txt
I support multiple pipes, so:
./pipex input.txt cmd1 cmd2 cmd3 cmd4 output.txt
is equivalent to Bash's:
< input.txt cmd1 | cmd2 | cmd3 | cmd4 > output.txt
open
: opens a file and returns a file descriptorclose
: closes a file pointed to by a file descriptorread
: reads from a file descriptorwrite
: writes to a file descriptormalloc
: allocates memory on the heapfree
: frees memory on the heapperror
: prints an error message to stderrstrerror
: returns string corresponding to an error codeaccess
: checks if we have access to a given filenamedup
: duplicates a file descriptordup2
: duplicates a file descriptor and gives it the value we wantexecve
: replaces the current process with the program givenexit
: exits a program with a given return statusfork
: duplicates the current processpipe
: creates a pair of file descriptors that can allow two processes to communicateunlink
: remove a filewait
: waits for a child process to finishwaitpid
: waits for a given child process to finish