find the output of these codes :
int main()
{
int c= fork();
printf("before execute \n");
if(c==0)
printf("child g %d\n", getpid() );
else{
printf("parent ch %d\n",c); /// what value of c
}
printf("after execute \n\n");
return 0;
}
//*****************************************************
int main()
{
int c= fork();
int s;
if(c==0){
printf("child g %d\n", getpid() );
}
else{
waitpid( c, &s, 0); /// what return ?
printf("parent ch %d\n",c);
}
/// it return c
return 0;
}
//*****************************************************
What line will print ?
int main()
{
int c=0;
c=fork();
c=fork();
c=fork();
c=fork();
c=fork();
puts("forked");
if(c==0)
puts("child here");
return 0;
}
int main()
{
int c= fork();
printf("before execute \n");
if(c==0)
printf("child g %d\n", getpid() );
else{
printf("parent ch %d\n",c); /// what value of c
}
printf("after execute \n\n");
return 0;
}
//*****************************************************
int main()
{
int c= fork();
int s;
if(c==0){
printf("child g %d\n", getpid() );
}
else{
waitpid( c, &s, 0); /// what return ?
printf("parent ch %d\n",c);
}
/// it return c
return 0;
}
//*****************************************************
What line will print ?
int main()
{
int c=0;
c=fork();
c=fork();
c=fork();
c=fork();
c=fork();
puts("forked");
if(c==0)
puts("child here");
return 0;
}
মন্তব্যসমূহ
একটি মন্তব্য পোস্ট করুন