250+ TOP MCQs on Signal Handling and Answers

C MCQs on “Signal handling”.

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
Answer: a
Clarification: 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
Answer: a
Clarification: 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?
a) sig_atomic_t
b) sig_signal_t
c) sig_signal_h
d) sig_stomic_h
Answer: a
Clarification: 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
Answer: c
Clarification: 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.
a) SIGILL
b) SIGTERM
c) SIGABRT
d) SIGFPE
Answer: c
Clarification: 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
Answer: a
Clarification: 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.
a) SIGILL
b) SIGTERM
c) SIGINT
d) SIGFPE
Answer: c
Clarification: 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
Answer: b
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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.

Leave a Reply

Your email address will not be published. Required fields are marked *