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

Casting methods, Special Casting Methods             1. Die casting : ...

Special Casting Methods             1. Die casting : Die casting is a permanent mould casting techniques in which molten metal is forced in the mould cavity under a pressure

Switching transistors, SWITCHING TRANSISTORS When a transistor is to be...

SWITCHING TRANSISTORS When a transistor is to be used as a switching device, it operates either as an open circuit (i.e. in the cut-off region) or as a short circuit (i.e. in t

Bragg''s spectrometer , It consists o a source of x ray, with a number of c...

It consists o a source of x ray, with a number of collimated slits. Crystal under investigation is mounted on a table, and the position of this table can be recorded on vernier sca

Financial management, The role of financial managers in the changing econom...

The role of financial managers in the changing economic scenario

Continuous casting, Continuous Casting : In essential, the process consist...

Continuous Casting : In essential, the process consists of pouring molten metal into a short vertical metal die or mould (at a controlled rate), which is open at both ends, coolin

Use of multicylinder engine, USE OF MULTICYLINDER ENGINE If, in a multi...

USE OF MULTICYLINDER ENGINE If, in a multi cylinder engine, power strokes are staggered, the limitation of flywheel can be overcome to a large extent. Torque diagram for 2 cyli

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