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

Matlab, The 3 sum problem: (20 pts.) Provided a 1D array of integers, find ...

The 3 sum problem: (20 pts.) Provided a 1D array of integers, find all combinations of 3 values from this set such that: a+b+c=0 For example, if one were provided with the set [3 1

Fire precautions - fire protection engineering, Fire precautions - fire pro...

Fire precautions - fire protection engineering: Fire precautions include: Protecting escape routes in fire resisting construction, Providing fire doors between

Roll-compacting, Q. Describe the continuous production of metal strip by ro...

Q. Describe the continuous production of metal strip by roll compacting of powder. Differentiate between impregnation and infiltration. Ans. Roll-compacting : It is the

Function ismember - set operations, function ismember - set operations: ...

function ismember - set operations: The function ismember receives two vectors as input arguments, and returns a logical vector which is of similar length as the first argumen

Kinematics, I want to make a model on kinematics need help.

I want to make a model on kinematics need help.

Life cycle of a product from raw materials, The Task: This project is a...

The Task: This project is a 50% of the whole assessment of the course. You are required to assess a life cycle of a product from raw materials, through the supply chain, manufa

Comparison of fp result with experiment, Comparison of FP result with exper...

Comparison of FP result with experiment At the lowest test lift coefficient the flow is just subcritical (in the sense that the Mach number of the flow component normal to the

Terrestrial telescope., how to making terrestrial tele scope an how its wor...

how to making terrestrial tele scope an how its work and formulation of terrestrial telescope

Cash flow diagrams, Cash Flow Diagrams We will use a cash flow approac...

Cash Flow Diagrams We will use a cash flow approach to analyze the flow of money through out a planning horizon. A cash flow occurs when money actually change hands. We will u

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