Answers

Question and Answer:

  Home  Linux Signal Handling

⟩ 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

b) this program will print "Child Exited"

Explanation:

The child process sends SIGCHILD signal to its parent as it terminates.

Output:

[root@localhost google]# gcc -o san san.c

[root@localhost google]# ./san

Child exited

[root@localhost google]#

 162 views

More Questions for you: