subject
Engineering, 24.03.2020 04:29 codie1103

The purpose of this assignment is to make sure that the students can work effectively with the fork, pipe, and dup, system calls. It should also grant some insight into how the shell enables input and output redirection behind the scenes.

For this assignment, you will be writing a single program that enters a loop in which each iteration prompts the user for two, single-line inputs. If the text of either one of the inputs is "quit", the program should immediately exit. If "quit" is not found, each of these lines of input will be treated as a command line to be executed. These two commands should be executed as if the user had typed command1 | command2 at the shell prompt, meaning that the standard output of the first command gets redirected into the standard input of the second command. (It should be noted that using cin >> will not grab a whole line; you will need to use another function instead.) You will need to be able to split the text entered by the user into the different command line arguments that comprise it. I do not care how this is accomplished, but some possibilities are to use the C function strtok, or a C++ istringstream object. You do not need to worry about escaping special characters when splitting the string for the purposes of this assignment; the split can be performed based on spaces alone. After these commands have both finished executing, your program should prompt for another pair of input commands to run, repeating the process over and over again until the user gives "quit" as inputRequirements• You may not use the system function to do this. You must make your own child processes, do the appropriate changes to the file descriptors in each of them, and have them use one of the exec calls to run the commands given by the user.• Use the pipe system call to create the file descriptors used to communicate between the two programs that are run.• If an error occurs at any point, there should be an appropriate error message printed to the standard error stream.• Your program must be able to handle user-specified commands that are up to 127 characters long.• Your program must be able to handle user-specified commands that contain up to five command-line arguments.• Make sure to close unused pipe file descriptors in all process. If you do not, your program is likely to stall.• Do not forget that this program involves a loop. After both programs have finished running (but not until), the program should go back to the beginning and prompt for two more commands to run.• Like all other programming assignments, this must be well-documented.

ansver
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, alyssabailey7545
Give heat transfer applications for the following, (i) gas turbines (propulsion) ) gas turbines (power generation). (iii) steam turbines. (iv) combined heat and power (chp). (v) automotive engines
Answers: 1
image
Engineering, 04.07.2019 18:10, lillygrl100
For the closed feedwater heater below, feedwater enters state 3 at a pressure of 2000 psia and temperature of 420 °f at a rate of ix10 ibhr. the feedwat extracted steam enters state 1 at a pressure of 1000 psia and enthalpy of 1500 btu/lbm. the extracted er leaves at an enthalpy of 528.7 btu/lbm steam leaves as a saturated liquid. (16) a) determine the mass flow rate of the extraction steam used to heat the feedwater (10) b) determine the terminal temperature difference of the closed feedwater heater
Answers: 3
image
Engineering, 04.07.2019 18:20, karatsgrande3772
Determine the damped natural frequencies and the steady state response of a decoupled damped forced two degrees of freedom system. 10ä1 + 2q1 20q1 10 cos t; 10q2 +4q2 + 40q2 10 cos t
Answers: 3
image
Engineering, 06.07.2019 02:30, jayjay5246
Air (c-1.006 kj/kg. k, r-0.287 kj/kg. k) enters a nozzle steadily at 280 kpa and 77°c with a velocity of 50 m/s and exits at 85 kpa and 320 m/s. the heat losses from the nozzle to the surrounding medium at 20°c are estimated to be 3.2 kj/kg. determine (a) the exit temperature and (b) the total entropy change for this process. solve this problem using constant specific heats.
Answers: 1
You know the right answer?
The purpose of this assignment is to make sure that the students can work effectively with the fork,...

Questions in other subjects:

Konu
Mathematics, 18.08.2019 22:10
Konu
Mathematics, 18.08.2019 22:10