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

Linear lateral dynamics, Linear lateral dynamics The second order (two ...

Linear lateral dynamics The second order (two degree of freedom) Dutch-Roll approximation is an approximation to the abovefourth order system for the Dutch Roll dynamics. A jus

Identify fire hazards - fire risk assessment , Identify fire hazards: ...

Identify fire hazards: In this part, the process appears to be concentrating on issues that can lead to fire but we have to remember to also consider the presence of a fire wi

Ratio analysis, calculate inventory turnover ratio, when only given current...

calculate inventory turnover ratio, when only given current assets $100,000, current liabilities, $25,000 sales $200,000 and quick ratio=1.5

Torque indication - aircraft engine, Torque indication: Turboprop and t...

Torque indication: Turboprop and turboshaft engines do not provide significant thrust through their jet pipes, so EPR would not be of any use in determining the thrust being pr

Fibre optics communications, explain the fibre optic communication system w...

explain the fibre optic communication system with block diagram

Applications of De, What are the applications of de.moivres theorem in soft...

What are the applications of de.moivres theorem in software engineering,computer science,programming and computer engineering? if there are any applications,then,what are that?

Fuels and lubrication technology, minimum mass of air required for complet...

minimum mass of air required for complete combustionof the HFO

Derivative securities, Let C (K) denote a European vanilla Call option with...

Let C (K) denote a European vanilla Call option with strike price K. Assume that all options are identical except for strike price, and strike prices satisfy K1 What are the no-ar

Application to the axial flow compressor, APPLICATION TO THE AXIAL FLOW COM...

APPLICATION TO THE AXIAL FLOW COMPRESSOR: In order for the compressor to deliver a high mass airflow for a minimum effort required to drive it, it is important that all the com

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

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