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
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
Explanation: The function raise defined under the header file signal. h reports a synchronous signal.
3. What is the type declared by the header file signal.h?
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?
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.
5. Select the macro that abnormally terminates the program.
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
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.
7. _________ gives receipt of an interactive attention signals.
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
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.
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
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
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.