11. Processes
Create 11_Processes subdirectory at sugon server and store all the code there.
Write 4 programs:
outredir.c command output_filename, execs a command with stdout redirected to output_filename
e. g.: ./outredir ls out_of_ls
allredir.c command infile outfile, forks and execs a command with both stdin and stdout redirection, then waits for it to terminate and printfs WEXITSTATUS(wstatus) received
e. g. ./allredir hexdump out_of_ls dump_file
argredir.c infile outfile command arg1 arg2 arg2 ...: rewrite previous program, but use execvp() for executing command with arguments
e. g. ./argredir out_of_ls dump_file hexdump -C
piperedir command1 command2 arg1 arg2 arg3 ..., forks and execs command1, then execs command2, connecting them through unnamed pipe
e. g. ./piperedir date hexdump -C
H/W
- Finish all tasks
Improve argredir.c to check error status of all operations performed and print an error message when en error is occurred
See RETURN VALUE (or alike) section of each function manpage
use perror
Write a new program pip2redir.c that resembles piperedir, but forks both child processes (as seen at lecture), waits for both to end and prints both commands exit status
Note wait() returns after either of children is stopped, you need to check if ECHILD is returned to indicate there is no more living child