Reference no: EM131166083
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.
How many allowable moves are needed to move the disks
: Describe the strategy you have used or would use in a recursive program to solve this problem.
|
Amount of initial investment
: You invested in classic cars 7 years ago. You have earned an average compounded annual rate of 22 percent. The investment is now worth $350,000. What was the amount of your initial investment?
|
Amount of the current liabilities
: The Corner Shoppe has a current ratio of 1.4, net fixed assets of $26,800, and total assets of $32,400. What is the amount of the current liabilities?
|
Determine the present value
: Determine the future value (FV) of this annuity if your first $5,000 is invested at the end of the first year.- Determine the present value.
|
Develop a C program for Linux called pipes
: 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..
|
What is a recurrence for the running time of select1
: Let T(n) be the running time of the modified Select1 on n items. How can you express the running time of Magic Middle in terms of T(n)?
|
What is the equilibrium price and quantity of cigarettes
: Suppose a public referendum is being held on whether or not to levy a tax on cigarettes. Currently, the supply of cigarettes is given by Qs = -900 + 200P. You estimate the demand for cigarettes to be Qd = 1200 - 50P. What is the equilibrium price ..
|
How do you find the second smallest element
: How do you find the minimum (i = 1) or maximum (i = n) in a set? What is the running time? How do you find the second smallest element? Does this approach extend to finding the ith smallest? What is the running time?
|
What are the typical features of mammals
: What are the typical features of mammals - What are the three major groups into which mammals are divided?
|