Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code below is not a typical way of handling fork() and pipe), but to test your understanding of their behaviors. The code works fully

The code below is not a typical way of handling fork() and pipe), but to test your understanding of their behaviors. The code works fully and you can try to run it.

int a = 0; int b = 0, intc, d;

int pfd[2]; // pipe file descriptor

void parent_function (int arg)

{ a = 2; b= 3; c=7; d= 8;

pipe (pfd):

if (arg I= 0) write (pfd[1], &c , sizeof(int)); else write (pfd[1]. &d sizeof(int)); printf ("parent: %d,%din", a, b);

close (pfd[1]);

B

M

1 Meet -

)

void child function ()

1 read (pfd[0], &a , sizeof(int));

read (pfdrOl. &b sizeof(int)). printf ("child:%d,%din", a, b);

close (ofdrOl):

void main ()

[int ret = fork 0);

parent_function (ret);

if (ret == 0) child_function ();

wait():

Give the outputs of the child process. Put each line of output in the corresponding box below. Your answer for each line should contain no space (e.g., parent:2,0), (e. g, child:2,0).

First output line:

Second output line:

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

4. Support and enliven your speech with effective research

Answered: 1 week ago