In this program
#include<stdio.h>
#include<signal.h>
#include<stdlib.h>
int main()
{
pid_t child;
child=fork();
switch(child){
case -1 :
perror("fork");
exit(1);
case 0 :
while(1){
printf("Child Process\n");
sleep(1);
}
break;
default :
sleep(5);
kill(child,SIGINT);
printf("The child process has been killed by the parent process\n");
break;
}
return 0;
}
#include<stdio.h>
#include<signal.h>
#include<stdlib.h>
int main()
{
pid_t child;
child=fork();
switch(child){
case -1 :
perror("fork");
exit(1);
case 0 :
while(1){
printf("Child Process\n");
sleep(1);
}
break;
default :
sleep(5);
kill(child,SIGINT);
printf("The child process has been killed by the parent process\n");
break;
}
return 0;
}
A. the child process kills the parent process
B. the parent process kills the child process
C. both the processes are killed by each other
D. none of the mentioned
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