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

  What are the models that describe use cases in more detail

What are the models that describe use cases in more detail? Which part of a use case description can also be modeled by using an activity diagram? List the parts or compartments of a fully developed use case description.

  Implement a drop-out stack using an array

The array implementation in Introduction to Collections - Stacks, keeps the top variable pointing to the next array position above the actual top of the stack.

  Write down a 2- to 3-page paper which compares and

designing and coding a procedure module or object can be complex and time consuming. once these elements of a computer

  Show the hits and misses and final cache contents

Using this references, show the hits and misses and final cache contents for direct-mapped cache with 16 one-word blocks

  How can ajax influence a web developer

What is the relationship between Web 2.0, SOAP, and XML.How can AJAX influence a Web Developer.

  Discuss other professions aside from health care and

brain saving technologies inc. and the t-health institute medicine through videoconferencing.in a three- to five-page

  Explain how this storage space works where it is located in

ram is a temporary storage space that is used to store program instructions and data. but accessing ram is inefficient

  Add a legend to indicate the shelf number

For the `UScereal` (**MASS**) data set, create a scatter plot of `calories` modeled by `sugars` using the `shelf` variable to create different plot characters.

  Describe an efficient externalmemory algorithm

Describe an efficient externalmemory algorithm for finding all the red-blue pairs in S. How many disk transfers does your algorithm perform?

  Are there sections missing

Using a Web browser, search for any information security policies used at your academic institution. Compare them to the ones discussed in this chapter.

  Define a contract with a managed security services

negotiate a contract with a managed security services (MSS) provider to outsource some of your company's security operations

  Produce a thresholded binary image

E27: Computer Vision Spring 2016 - PROJECT 1. Thresholding. Your system will produce a thresholded binary image where the non-zero pixels correspond to objects of interest (foreground), and the zero pixels correspond to background. You will need t..

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