C Questions and Answers – Signal Handling

«
»

This set of C MCQs focuses 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
View Answer

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

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.

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.

advertisement
advertisement

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.

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.
advertisement

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.

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.
advertisement

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.

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.
advertisement

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.

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!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter