Write a program in C that mimics the usage of UNIX mechanisms with system calls only.
Program name | pipex |
---|---|
Turn in files | Makefile, pipex.h, pipex.c, pipex_utils.c |
Makefile | NAME, all, clean, fclean, re |
Arguments | file1 cmd1 cmd2 file2 |
External functions | • open, close, read, write, malloc, free, perror, strerror, access, dup, dup2, execve, exit, fork, pipe, unlink, wait, waitpid • ft_printf and any equivalent YOU coded |
Libft authorized | Yes |
Your 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.
Your project must comply with the following rules:
- You have to turn in a Makefile which will compile your source files. It must not relink.
- You have to handle errors thoroughly. In no way your program should quit unexpectedly
(segmentation fault, bus error, double free, and so forth). - Your program mustn’t have memory leaks.
- If you have any doubt, handle the errors like the shell command:
< file1 cmd1 | cmd2 > file2