Question
C program called minishell that creates two child processes: one to execute 'ls' and the other to execute 'sort'. After the forks, the original parent
C program called minishell that creates two child processes: one to execute 'ls' and the other to execute 'sort'. After the forks, the original parent process waits for both child processes to finish before it terminates. The standard output of 'ls' process should be piped to the input to the 'sort' process. Make sure you close the unnecessary open files for the three processes
*The program should fork off 2 children, one for ls and one for sort. The one for ls can have options if desired.
*The program should create a pipe using the pipe function and communications between the children should be through the pipe.
*Each child should use dup2 after the fork to set up the io for the pipe
*Each child should close the unused end of the pipe on its end
*One of the exec methods should be used to replace the code in each child
*The parent should close the unused ends of the pipe and should wait for the children to finish before ending. No output should happen after each child ends
*Create a Makefile to build your source code into an executable. The Makefile should also include a target 'clean' to clean up miscellaneous files (*.o, the executable file, *~, core, etc.).
*No other files other than the source file and Makefile
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started