Sail E0 Webinar
Question

What will be the output of the following program.
#include<stdio.h>
int main()
{
int pid;
int retvalue;
int p[2];
pipe(p);
char buff[6]="hello";
pid=fork();
if(pid == 0)
{
exit(0);
}
else
{
sleep(1);
close(p[0]);
retval = write ( p[1], buff);
printf("%d",retval);
}
}



Options:
A .  The program prints 0
B .  The program prints -1
C .  The program ends abruptly wotout printing anything
D .  The program prints 1
Answer: Option B



Submit Your Solution Below and Earn Points !
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers