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

  Explain how toggle mode is the same as division by two

What is the difference between a synchronous input (D, J, or K) and an asynchronous input (PR or CLR)?

  Develop block diagrams for floating point add pipeline

Develop the detailed block diagrams for each of the stages in the floating-point add pipeline of Figure. Assume the IEEE standard representation.

  What is the underlying rationale for diversity jurisdiction

Describe a technological change you are familiar with that has changed a law.

  How you can change the above table into 2nf

Is this table in first normal form? Why or Why Not? Why it is not in 2NF? How you can change the above table into 2NF.

  What is a voluntary response sample

Voluntary Response Sample Some magazines and newspapers conduct polls in which the sample results are a voluntary response sample.

  Delete an existing product from the database in php

In the PHP scripts you create, refer to the DSN datasource as flamingo. though its not in your own folder or directory, it has been set up as a SYSTEM DSN, so your PHP script would have access to it.

  What two basic functions does ip implement

What two basic functions does IP implement, What four key mechanisms does IP use to provide its service

  Develop a uml class diagram diagram for a classic car

In this project, you have the opportunity to develop a UML class diagram diagram for a classic car museum database system.

  Compute how much federal and state tax you need to pay

Write down a Java application to calculate how much federal and state tax you require to pay. The program should accomplish the following task: ask your name, yearly income, federal tax rate, and state tax rate, and compute the tax you need to pay.

  Prompt the user to enter a string of their choosing

Prompt the user to enter a string of their choosing. Output the string. Extend the program further by implementing the output_without.

  Test a program that generates 1000 random numbers

write and test a program that generates 1000 random numbers between 1 and 6 and stores them in a data file.Write down a second program the takes the data produced by the first program and analyses it to produce a table showing the number of times ..

  Converting the sum of elements of array into octal format

Provided an array of ints named x and an int variable named total that has already been declared, write down some code which places the sum of all the elements of the array x into total.

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