Question: C program Write a program that forks one process. Have the new process execve the program named /usr/bin/bc. Use dup/dup2 and pipes to establish a

C program  C program Write a program that forks one process. Have the

Write a program that forks one process. Have the new process execve the program named /usr/bin/bc. Use dup/dup2 and pipes to establish a way for the original process to pass stdin to bc, and to capture its stdout. BE SURE TO HAVE THIS AS THE FIRST EXECUTABLE LINE IN BOTH PROCESSES: alarm(60) The original process should read lines of input from a file named as the first command-line arg. Subsequent command-line args should be handed to bc as if they were entered on its command-line; there will be no more than 3. Each line should be handed to the bc process on its stdin via a pipe, the line of input printed, and output (if any) printed like this: in: line_of_input from_file bc: output-printed-by-bc # this may be 0 or several lines blank-line ## print a blank line here Note that bc will not always print something, e.g. it will not reply to: The select system call can be useful to determine if data is available on a descriptor. Do not pause more than 1 second for data here. I will run tests by typing commands like this: /p4 infilename1 ./p4 infilename2-1 # the-l will be passed as arg to bc

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!