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()

machine molding, Machine molding is suitable for the faster and uniform qu...

Machine molding is suitable for the faster and uniform quality moulds, needed for mass production of castings. For preparing the moulds, various moulding machines are used. Majorit

Financial management, Explain and identify the different sources of finance...

Explain and identify the different sources of finances which are available to businesses and which sources of finance are internal sources and which are external sources?

Genetic algorithm procedure, Genetic Algorithm Procedure Generate a ...

Genetic Algorithm Procedure Generate a "pool" of "genes" randomly These genes are then "mated" to produce the "mated" to produce the next generation Best genes have a

Homework, What are the no-arbitrage lower bound, and the no-arbitrage upper...

What are the no-arbitrage lower bound, and the no-arbitrage upper bound, of the vertical spread C(k1) - C(k2) ?

Couplings in engine, Couplings: Because of the requirement to make main...

Couplings: Because of the requirement to make maintenance tasks such as engine removal/refit, gearbox removal/refit easier, it is necessary to have a means of coupling the turb

Effects of temperature and altitude on engine, Effects of Temperature and A...

Effects of Temperature and Altitude. Cold and/or Low On cold days the air density will increase. If the engine has a ‘part throttle rating' and the throttle is advanced to

Iosipescu shear test, A second way to determine the shear modulus is to use...

A second way to determine the shear modulus is to use the Isopescu shear test. The sample is placed in a jig and loaded as shown. Under load, a region of pure shear exists

Inner rooms - means of escape, Inner rooms - means of escape: I nner...

Inner rooms - means of escape: I nner rooms are rooms from which the means of escape require people to travel through another room (called the access room).  These are comm

Long period oscillation , The phugoid is a relatively low-frequency oscilla...

The phugoid is a relatively low-frequency oscillation in which kinetic and potential energies are exchanged. The mode is generally characterized by low damping and approximately co

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