Write end of the pipe and then executes

Assignment Help Computer Engineering
Reference no: EM132196223

Write 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 "ps-aux" command.

Child 2 redirects its input from stdin to the read end of the pipe, then it executes the "sort -r -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 "ps-aux | sort-r-n-k 5". You must use the fork(), pipe(), dup2(), close(), execlp() functions (or other exec() variation).

Reference no: EM132196223

Questions Cloud

Write down a c program to generate a matrix : Write down a C program to generate a matrix (2-D Array) of integers in the range 1 to 100.
Write a c program that initializes an integer array : Write a C program that initializes an integer array, and two scalar values a and b.
Write a program to execute the game craps : Write a C++ program to execute the game craps. Rules for the game are below and instructions for the code are afterward.
Write a c program to implement a four function calculator : Write a C program to implement a four function calculator. The program should prompt the user for a formula.
Write end of the pipe and then executes : Child 2 redirects its input from stdin to the read end of the pipe, then it executes the "sort -r -n -k 5" command.
Calculate the average of the given numbers : Write a C++ program to read 10 integer numbers from the user and stores/puts them in an array.
Display the sum array : Write a C program that inputs 5 elements into each of 2 integer arrays. Display the sum array.
Prompts the user to enter a number and prints the number : Write a C++ program that prompts the user to enter a number and prints the number and a message that states.
Calculate the total rain for the entire year : Write C++ Program which Prompts The use to The daily Average For 12 months (jan Dec) .

Reviews

Write a Review

Computer Engineering Questions & Answers

  Make the title bold and increase the font size of it

Create a new spreadsheet named final.xlsx. Enter the following data into the worksheet. Make the title bold and increase the font size of it.

  Define the terms precision and reliability

Sample Evaluation. Gloria Bush has performed a sampling plan to estimate the number of children per household in her neighborhood.

  What baseline data do you need for this

There is a 20% chance that he will find a computer which has an active worm; in this case, nothing happens (whether the worm is active for one or two days).

  How do you program a spritesheet in java

How do you program a spritesheet in Java? Is there a general code that runs the sprites, like, is it one coding sequence you can use for any spritesheet?

  Working with cross-functional teams and offshore teams is

working with cross-functional teams and offshore teams is common in large it project deployments. similarly your

  Write a program that draws two solid squares

Write a program that draws two solid squares: one in pink and one in purple. Use a standard color for one of them and a custom color for the other.

  Drawbacks of working with multiple tables

rePresent an instance of a situation where multiple tables would be appropriate in an application and discuss why this approach is needed in this scenario.

  Write an algorithm in pseudocode to find a primitive root

Write an algorithm in pseudocode to find a primitive root for the set ZP*. Write an algorithm in pseudocode to find all primitive roots for the set ZP*.

  Write a heap method named incrementpriority

Write a Heap method named incrementPriority that, given the position of an element in the array just described, adds 1 to its value and reorganizes the heap.

  Handling of global ethics issue by organizations

Our textbook describes the ethics as “the principles of right and wrong which individuals utilize in order to make choices in order to guide their behaviors”.One global ethical issue is software piracy. What can the organizations such as Microsoft ..

  Create a picture by sketching straight lines

Write a routine that allows a designer to create a picture by sketching straight lines with a rubber-band method.

  How to use the schedule performance index

Use CPI to calculate the estimate at completion (EAC) for this project. Is the project performing better or worse than planned.

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