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;
}
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
Answer: Option B
Related Questions on Linux
What command is used to count the total number of lines, words, and characters contained in a file?
A. countw
B. wcount
C. wc
D. count p
E. None of the above
What command is used with vi editor to delete a single character?
A. x
B. y
C. a
D. z
E. None of the above

Join The Discussion