Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Which of the following are problems with this style of implementation? Select all that apply. A. the run_pipeline function could return while ./B is still

image text in transcribed

Which of the following are problems with this style of implementation? Select all that apply.

A. the run_pipeline function could return while ./B is still running

B. the run_pipeline function could return while ./A is still running

C. the pipe created by the call to pipe() shown above will not be shared by the process that runs ./A and the process that runs ./B

D. ./A could end up being run twice as a result of a single call to run_pipeline()

For the following two questions, consider the following Unix-style shell command and its potential implementation below. When the command ./A output.txt is run, the input of a should come from the file input.txt, the input of e should come from the output of A, and the output of e should be sent to the file output.txt. A potential but flawed implementation of this command as C code might look like the following where an ellipsis (...) represents zero or more lines of code that is not shown: void run_pipeline() { pid_t pl, p2; .../+ 1 +/ int fds[2]; pl = fork() if (p1 == 0) { ... /* 2 */ int fds[2]; pipe(fds); p2 = fork(); if (p2 == 0) { ... /* 3 */ execv("./B", ...); handle_error(); exit(1); } else { execv("./A, ...); handle_error(); exit(1); } .../* 5 */ waitpid(p1, NULL, 0); } You may assume that the code represented by the ellipses (...s) does not include any calls to fork(), execv(), or any other function that would start a new process or load a different program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago