835 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
4
Philosophical_Virus asked Dec 10, 2023
965 views
Int main (){fork();printf("a");fork();printf("b");return 0;}How many distinct outputs are possible of above code? And also give outputs