Develop a c program

Assignment Help C/C++ Programming
Reference no: EM131166024

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). You can edit your program with the geditapplication, available from the command line. Or install emacs using command "sudo apt-get install emacs" and learn to use it. 

 

Reference no: EM131166024

Questions Cloud

How can you make improvements with a new system : What does the credit card charge form indicate about the existing system? How can you make improvements with a new system?
Explain the four elements of negligence : Discuss the court's findings and explain how the court determined this was a negligence case rather than an intentional tort. Explain the four elements of negligence and the reasoning of the court when analyzing each element.
What implications does the business model have for systems : Do you agree with Dogster's view, or should companies aim for "zero-defect" operations? Why or why not? What implications does this business model have for systems analysts?
What are ebit under the best case scenario : The estimated sales price is $80 a unit, plus or minus 4 percent. Variable costs are estimated at $55 a unit, plus or minus 5 percent, and the fixed costs are $25,000, plus or minus $25,000. What are EBIT under the best case scenario?
Develop a c program : 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 ex..
What techniques can you use to identify improvements : What techniques can you use to identify improvements? Choose one technique and apply it to this situation- what improvements did you identify?
Explain the costs and the benefits of the production : Why do you think your policy would work in reducing the total amount of emissions? In your answer, explain the costs and the benefits of the production and consumption of the good, as well as the negative externality
Which approach seems to be more successful : A system development project may be approached in one of two ways: as a single. Which approach seems to be more successful? Why do you suppose that this is true?
What is the value of expressing one probability in events : If you roll two dice, what is the probability of an even sum or a sum of 8 or more?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a class with the following static methods

Wordcount: This method should accept a reference to a String object as an argument and return the number of words contained in the object.

  Where is the error in this code sequence?

Where is the error in this code sequence?Explain what the problems are and how to fix them.

  Write a method named negative sum

Write a method named negativeSum that accepts a Scanner as a parameter reading input from a file containing a series of integers, and determine whether the sum starting from the first number is ever negative

  Program that asks the user to enter the number of miles

Write a C - program that asks the user to enter the number of miles traveled and the number of gallons of gasoline consumed. It should then calculate and display the miles-per-gallon value. Confine your output to 1 decimal place.

  Design and code a new function that accepts as parameters

design and code a new function that accepts as parameters the gross pay by value and the federal tax state tax local

  Write a class called fraction

Write a class called Fraction (this is not related to problem 2 from the text).

  Write a program that creates an array of 200 random numbers

Write a program that creates an array of 200 random real numbers between 0 and 200.  Using the statistics library, calculate and output the following: mean, median, variance, standard deviation, maximum value, and minimum value.

  Create a function gcd

Create a function gcd(a, b) that receives two integers and returns the greatest common denominator of the two integers.

  Display the array, the average and the number of days above

Write a program that stores the daily temperatures for the month of April in an array name dailytemp. Calculate the average temperature for the month and the count the number of days that the daily temperature was above the average.

  Display the commands

Display the commands(s) used to do the following (and show the results): see the df command to view file system use in megabytes.

  How many elementary operations are used in algorithm

How many elementary operations are used in the following algorithm? The elementary operations are comparison operations (such as > and

  Statements that return container data only return container

Make sure all return statements that return container data only return container data.  If a return statement returns container data under certain conditions, but another return statement returns something that is not container data under other condi..

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