Linux OS Management Question:
Download Questions PDF

What is the output of the below code?

void exit_handler1();
void exit_handler2();
int main() {
int pid;
atexit(exit_handler1);
atexit(exit_handler2);
pid = fork();
if(pid == 0) {
_exit(0);
} else {
sleep(2);
exit(0);
}
return 0;
}

a) Only child executes the exit_handler 1 and 2.
b) Only parent executes the exit_handler 1 and 2.
c) Both parent and child executes the exit_handler 1 and 2.
d) Neither parent nor child executes the exit_handler 1 and 2.

Linux Operating System Management Interview Question
Linux Operating System Management Interview Question

Answer:

b) Only parent executes the exit_handler 1 and 2.

Download Linux Operating System Management Interview Questions And Answers PDF

Previous QuestionNext Question
What is output of the following program?

int main() {
fork();
fork();
fork();
if (wait(0) == -1)
printf("leaf childn");
}

a) "leaf child" will be printed 1 times
b) "leaf child" will be printed 3 times
c) "leaf child" will be printed 4 times
d) "leaf child" will be printed 8 times
The maximum time slice that can be given to a process in Linux (where tick is 10ms) is:
a) 150ms
b) 10ms
c) 300 ms
d) 600ms