Answer: Provided in the explanation section
Step-by-step explanation:
int r, pipeFDs[2];
char message[512];
pid_t spawnpid;
pipe(pipeFDs);
spawnpid = fork();
switch (spawnpid)
{
case 0:
close(pipeFDs[0]); // close the input file descriptor
write(pipeFDs[1], "hi process, this is the STUFF!!", 21);
break;
default:
close(pipeFDs[1]); // close output file descriptor
r = read(pipeFDs[0], message, sizeof(message));
printf("Message received from other: %s\\", message);
break;
}
Observation of the program:
- The read() call may block until data becomes available
- If the read() call blocks, the process will be suspended until data arrives
- Pipes can fill, which will cause the write() call to block until the read() call is able to read data from the pipe
⇒ Therefore,Option 1,3 and 5 correct
Cheers i hope this helped !!!