Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago