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

  Viewer features of the application

Sharon has started to use both the stock details management and the file information viewer features of the application. However, while using the file information viewer application, she accidentally enters the path of a folder that does not exist..

  Using songs.dat in our folder

Using songs.dat in our folder on the P: drive, construct a playlist of 10 random songs. Use a struct to hold the song data (name and time in seconds), and output the playlist (song name and time,

  Draws a single level for a "rogue­like" computer game

You will write a program that draws a single level for a "Rogue­like" computer game. The program will parse a line of input text from an input file (room.txt), use the parsed text to determine the shape of the room and its contents and then draw the ..

  Up through 2 to the 10th power

program should compute and output all of the "powers of two" from 2 to the 0th power, up through 2 to the 10th power.

  Communication protocols and devices

Can you help me prepare a presentation that examines and depicts a cluster connected over a LAN and provide the communication protocols and devices at each level of the OSI model are discussed and depicted in a diagram in the presentation.

  Economy of kenya has a budget deficit

The economy of Kenya has a budget deficit of KSH 500B. This deficit is likely to be funded through domestic borrowing and taxation. Using an appropriate model, explain the macroeconomic implications of such a move.

  Statement that declares and stores the elements

Write a statement that declares and stores the elements of the following array into a vector object:

  Implement a class to represent a matrix

Implement a class to represent a matrix. While doing this exercise, you are allowed only to use C++ primitive types and arrays. You may not use STL in your Matrix definition. You must use dynamic memory.

  What are overloaded methods

Overloaded methods for the operations of adding, subtracting, multiplication, and division will need to be created requiring one or two arguments. The single argument is added to, subtracted from, divided over, or multiplied by the running answer...

  Question regading the mean value theorem

Consider the function f(x) = x^2 on the interval [0,1]. According to the Mean Value Theorem, there must be a number c in (0, 1/2 ) such that f ′(c) is equal to a particular value d. What is d?

  Converts an infix expression into a postfix expression

My goal is to implement a C++ program that converts an infix expression into a postfix expression and then evaluates the postfix expression. I am using the Stack and Queue classes I developed with a List class (linked list) that manages the data i..

  Determining the corresponding node labels

Use binary reflected Gray code (RGC) to determine how a 16-node linear array can be mapped to a 4-D hypercube. You must derive the 4-bit Gray codes and the corresponding node labels of a 4-D hypercube. Draw the mapping of the 16-node linear array ..

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