⟩ How to run a process in the background? a) & b) * c) ? d) |
a) &
a) &
Which of the following signal cannot be handled or ignored? a) SIGINT b) SIGCHLD c) SIGKILL d) SIGALRM
What happnes as the signal SIGINT hits the current process in the program? #include<stdio.h> #include<signal.h> void response (int); void response (int sig_no) { printf("Linuxn"); } int main() { struct sigaction act; act.sa_handler = response; act.sa_flags = 0; sigemptyset(&act.sa_mask); sigaction(SIGINT,&act,0); while(1){ printf("googlen"); sleep(1); } return 0; } a) the process terminates b) the string "Linux" prints c) the string "Linux" prints and then process terminates d) none of the mentioned
This program will print #include<stdio.h> #include<signal.h> #include<unistd.h> void response (int); void response (int sig_no) { printf("%s is workingn",sys_siglist[sig_no]); } int main() { alarm(5); sleep(50); printf("googlen"); signal(SIGALRM,response); return 0; } a) "google" b) "Alarm clock" c) nothing d) none of the mentioned
What is the output of this program? #include<stdio.h> #include<signal.h> #include<stdlib.h> void response (int); void response (int sig_no) { printf("%sn",sys_siglist[sig_no]); printf("This is singal handlern"); } int main() { pid_t child; int status; child = fork(); switch (child){ case -1 perror("fork"); exit (1); case 0 kill(getppid(),SIGKILL); printf("I am an orphan process because my parent has been killed by men"); printf("Handler failedn"); break; default signal(SIGKILL,response); wait(&status); printf("The parent process is still aliven"); break; } return 0; } a) the child process kills the parent process b) the parent process kills the child process c) handler function executes as the signal arrives to the parent process d) none of the mentioned
Which one of the following is not true about this program? #include<stdio.h> #include<signal.h> void response (int); void response (int signo) { printf("%sn",sys_siglist[signo]); signal(SIGSEGV,SIG_IGN); } int main() { signal (SIGSEGV,response); char *str; *str = 10; return 0; } a) kernel sends SIGSEGV signal to a process as segmentation fault occurs b) in this process signal handler will execute only one time of recieving the signal SIGSEGV c) both (a) and (b) d) none of the mentioned
What is the output of this program? #include<stdio.h> #include<signal.h> void response (int); void response (int sig_no) { printf("%sn",sys_siglist[sig_no]); } int main() { pid_t child; int status; child = fork(); switch(child){ case -1 perror("fork"); case 0 break; default signal(SIGCHLD,response); wait(&status); break; } } a) this program will print nothing b) this program will print "Child Exited" c) segmentation fault d) none of the mentioned
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
What will print as the SIGINT signal hits the running process of this program? #include<stdio.h> #include<stdlib.h> #include<signal.h> void response (int); void response (int sig_no) { printf("%s",sys_siglist[sig_no]); } int main() { signal(SIGINT,response); while(1){ printf("googlen"); sleep(1); } return 0; } a) Interrupt b) Stop c) Terminate d) none of the mentioned
What happens as the SIGINT signal hits the running process of this program? #include<stdio.h> #include<signal.h> #include<stdlib.h> int main() { pid_t child; signal(SIGINT,SIG_IGN); child=fork(); switch(child){ case -1 perror("fork"); exit(1); case 0 while(1){ printf("Child Processn"); sleep(1); } break; default while(1){ printf("Parent Processn"); pause(); } break; } return 0; } a) child process terminates b) parent process terminates c) both child and parent process ignores the signal d) none of the mentioned
What will happen if we press "Ctrl+c" key two times after running this program? #include<stdio.h> #include<signal.h> void response(int); void response(int sig_no) { printf("Linuxn"); signal(SIGINT,SIG_DFL); } int main() { signal(SIGINT,response); while(1){ printf("googlen"); sleep(1); } return 0; } a) process will terminate in the first time b) process will terminate in the second time c) process will never terminate d) none of the mentioned