Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Linux OS Interviews:Awk ProgrammingBash Arithmetic ExpressionsDevice DriversGCC CompilerLinux AdministratorLinux CommandsLinux DebuggingLinux EnvironmentLinux GeneralLinux IPCLinux MakefileLinux OSLinux OS EditorsLinux OS ManagementLinux OS ShellLinux Proc FilesystemLinux Search PatternLinux Shared & Static LibrariesLinux Socket ProgrammingLinux Startup and ShutdownLinux SysfsLinux SystemsLinux ThreadsLinux UbuntuSignal HandlingSystem Calls
Copyright © 2018. All Rights Reserved
Signal Handling Interview Question:
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 Processn");
sleep(1);
}
break;
default :
sleep(5);
kill(child,SIGINT);
printf("The child process has been killed by the parent processn");
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
Submitted by: Murtazab) the parent process kills the child process
Explanation:
The parnet process kills the child by sending a signal.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Child Process
Child Process
Child Process
Child Process
Child Process
The child process has been killed by the parent process
[root@localhost google]#
Submitted by: Murtaza
Explanation:
The parnet process kills the child by sending a signal.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Child Process
Child Process
Child Process
Child Process
Child Process
The child process has been killed by the parent process
[root@localhost google]#
Submitted by: Murtaza
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.