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

Tcp/ip, Discuss the effect of supernetting on routing and explain how the i...

Discuss the effect of supernetting on routing and explain how the issue has been tackled. Effect: increased routing information

Automatic synchronising - propellers, AUTOMATIC SYNCHRONISING: Automa...

AUTOMATIC SYNCHRONISING: Automatic Synchronisation uses engine driven synchronising alternators to detect electrically any increase or decrease in a slave engine's speed.  Ea

Sprinkler system - fire protection engineering, Sprinkler system - fire pro...

Sprinkler system - fire protection engineering Sprinkler systems may be installed in a building to achieve a number of different objectives.  Very often the primary reason for

Quantitative, Case 1: Decision Analysis Flifla sells tomatoes every day in...

Case 1: Decision Analysis Flifla sells tomatoes every day in Suk al Marqazi, the downtown fruit and vegetable market. He finds that he can order tomatoes in crates of 25 kg and he

Aeroengines - fluent , Installing FLUENT on a MWS machine Fluent was origi...

Installing FLUENT on a MWS machine Fluent was originally developed on unix and graphical output was provided by calls to the X Windows graphics system For this reason provided by c

Human Motion Kinetics, Beginning from rest when theta=10 degrees, a 30-kg c...

Beginning from rest when theta=10 degrees, a 30-kg child slides without kinetic friction down the slide which is in the shape of a 2.5 meter circular arc. Determine the child''s sp

Fundamentals of lift and drag , Lift and drag are merely the resolved compo...

Lift and drag are merely the resolved components in specific directions of a resultant aerodynamic force caused by the relative velocity V of the vehicle through the air. If al

Blending of metal powder, Q.5 Explain briefly the Blending of metal powders...

Q.5 Explain briefly the Blending of metal powders. Ans. Blending of Metal Powder:              The procedure of blending (mixing) powders is taken out for the followi

Gas turbine fuel properties - aircraft design, Gas turbine fuel properties ...

Gas turbine fuel properties and specification In the earliest days of the gas turbine engine, kerosene was regarded as the most suitable fuel. It commended itself on the grounds

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