Question: Proper includes and declarations have been made but not shown below ( pseudo - code ) . The size of an integer is 4 bytes

Proper includes and declarations have been made but not shown below (pseudo-code). The size of an
integer is 4 bytes and this of a character is 1 byte. Based on the snippet below, investigate the following:
Q1: Remove lines A and C altogether but keep B and D.
Q2: Remove lines B and D altogether but keep A and C.
In Q1 and Q2 what are the final values of r1, r2, r3, r5, r6, r7? Are there orphans or zombies at the end?
int pipefd[2];
pid_t res; //size of res is 8 bytes
char ch[50];
int r1, r2, r3, r4, r5, r6, r7;
pipe(pipefd);
res = fork();
if (res >0){
sleep(5); // line A
r1= write(pipefd[1],&res,2*sizeof(r4));
sleep(5); // line B
r2= write(pipefd[1],&r1,2*sizeof(char));
printf(Finished!);
r7= waitpid(-1,&status,WUNTRACED|WNOHANG);
sleep(20);
close(pipefd[

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!