C Questions and Answers – Signal Handling

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Signal Handling”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

1. Select the right statement.
a) synchronous signal occurs because of the action that your program takes
b) synchronous signal occurs because of action outside your program
c) asynchronous signal occurs because of the action that your program takes
d) division by zero is asynchronous
View Answer

Answer: a
Explanation: Synchronous signal occurs because of the actions that your program takes.

2. What does raise functions declared in signal.h do?
a) reports a synchronous signal
b) let’s you specify handling of signals
c) reports a asynchronous signal
d) doesn’t let you specify handling of signals
View Answer

Answer: a
Explanation: The function raise defined under the header file signal. h reports a synchronous signal.

advertisement
advertisement

3. What is the type declared by the header file signal.h?
a) sig_atomic_t
b) sig_signal_t
c) sig_signal_h
d) sig_stomic_h
View Answer

Answer: a
Explanation: The only type declared in signal.h is sig_atomic_h.
This is of int type and used as a variable in signal handling.

4. Which among the given header file is used to handle different signals reported during program execution?
a) stdarg.h
b) assert.h
c) signal.h
d) setjmp.h
View Answer

Answer: c
Explanation: signal.h is the header file that defines one type and two functions and many macros to handle different signals reported during the execution of the program.
Note: Join free Sanfoundry classes at Telegram or Youtube

5. Select the macro that abnormally terminates the program.
a) SIGILL
b) SIGTERM
c) SIGABRT
d) SIGFPE
View Answer

Answer: c
Explanation: SIGABRT is the macro defined under the header file signal.h which terminates the program abruptly.

6. Which of the following is the correct description of the macro SIGFPE?
a) erroneous arithmetic operation such as zero divide
b) invalid access to storage
c) termination request sent to the program
d) receipt of the interactive attention signal
View Answer

Answer: a
Explanation: SIGFPE is the macro defined under the header file signal.h which is an erroneous arithmetic operation such as zero divide, or operation resulting in overflow.
advertisement

7. _________ gives receipt of an interactive attention signals.
a) SIGILL
b) SIGTERM
c) SIGINT
d) SIGFPE
View Answer

Answer: c
Explanation: SIGINT gives receipt of an interactive attention signals.

8. The sig argument specifies the signal, which may be any signal except _______ and _________
a) SIG_DFL, SIG_IGN
b) SIGKILL, SIGSTOP
c) SIG_KILL, SIG_STOP
d) SIGCHLD, SIG_IGN
View Answer

Answer: b
Explanation: The sigset() function is used to modify signal dispositions. The sig argument specifies the signal, it can be any signal except SIGKILL and SIGSTOP.
advertisement

9. void (*signal(int sig, void (*func)(int)))(int);If the value of func is SIG_IGN then _________
a) the signal will be ignored
b) default handling for that signal will occur
c) The signal() function will fail to execute
d) the signal will be ignored
View Answer

Answer: a
Explanation: SIG_IGN is one of the ways in signal() function in which receipt of the signal number sig is subsequently handled. The signal will be ignored if the value of func is SIG_IGN.

10. In the c library function void (*signal(int sig, void (*func)(int)))(int), which statement is true with respect to func?
a) func is a pointer to the function
b) func is pointer to sig
c) func is a static variable
d) func is a pointer that points to all type of data
View Answer

Answer: a
Explanation: The declaration of the function signal() is given by
void (*signal(int sig, void (*func)(int)))(int). In this ‘func’ is a pointer to the function defined by the programmer or one of the following predefined functions:
SIG_DFL and SIG_IGN.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.