818 views
1 votes
1 votes

what is the output of the following program?

int ret = fork();
if(ret == 0) {
    exec(some_binary); // this call fails
    printf("child ");
}else {
    wait();
    printf("parent\n");
}

 

  1. Runtime Error
  2. child

  3. parent

  4. child parent

1 Answer

1 votes
1 votes

Runtime Error

wait() system call needs an argument "status" so its syntax should be like wait(&status).

 

 

Related questions

2 votes
2 votes
3 answers
3
Philosophical_Virus asked Dec 10, 2023
768 views
Int main (){fork();printf("a");fork();printf("b");return 0;}How many distinct outputs are possible of above code? And also give outputs
3 votes
3 votes
1 answer
4
24aaaa23 asked Oct 1, 2023
723 views
Consider the following code segment :int main (void) { for (int i=2; i<=5; i++) { fork( ); }printf (“GOCLASSES”);How many times “GOCLASSES” is printed by the ab...