C programming fork() dub2(), Other Engineering

Assignment Help:
develop a C program for Linux called pipes.c that does the following:
In the main() function, it creates a pipe using the pipe() function, then creates two child processes with fork(). Child 1 redirects stdout to the write end of the pipe and then executes with execlp() the "ls -al" command. Child 2 redirects its input from stdin to the read end of the pipe, then it executes the "sort -n -k 5" command.
After creating both children, the parent process waits for them to terminate before it can exit.
Note that you may have to create Child 2 first, followed by Child 1.

The parent program does the same thing as a shell that runs the command "ls -al | sort -r -n -k 5".

You must use the fork(), pipe(), dup2(), close(), execlp() functions (or other exec() variation).

Related Discussions:- C programming fork() dub2()

Presintering, Presintering is an operation in which the powder metallurgy ...

Presintering is an operation in which the powder metallurgy components after compaction are heated for a short time to a temperature considerably below the final sintering tempera

Architectural graphics, How to draw schiography in a perspective view of an...

How to draw schiography in a perspective view of an object

Speed control in aircraft engine, Speed control in Aircraft Engine: Bec...

Speed control in Aircraft Engine: Because the APU is designed to run at a constant rpm, some means must be provided to control this speed. Such a control device is known as a

Manufacturing definition and its importance, Economic Definition :  Manufa...

Economic Definition :  Manufacturing increase the value of product. Technological Definition :  Manufacturing is a process which gives required strength, shape and size of t

Mechanical engineering, What is the specific heat of water at different pre...

What is the specific heat of water at different pressure and different temperature? Is it possible to boil the water below atmospheric pressure and use as a hot bathing water?

Simulation, A system is a walk-in medical clinic; a simulation is used to d...

A system is a walk-in medical clinic; a simulation is used to determine staffing levels. Under what circumstances would it be appropriate to use a terminating simulation or a stead

Risk Decomposition, Analyze two stocks from an industry of your choice in t...

Analyze two stocks from an industry of your choice in terms of risk decomposition, specifically portfolio variance eq. You should pick 2 firms that you have a certain degree of fam

Derive, derive the power in case of r-l circuit

derive the power in case of r-l circuit

Health care finance basic tool for nonfinancial managers, based on your man...

based on your managemet style or your personal perspective, discuss how you developed your viewpoint how it will influence the way you manage, and what challenges you migt face if

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd