010-100 · Question #59
Pressing the Ctrl-C combination on the keyboard while a command is executing in the foreground sends which of following signal codes?
The correct answer is B. 2 (SIGINT). Pressing Ctrl-C in a terminal sends signal number 2, SIGINT, to the foreground process, requesting it to interrupt and terminate.
Question
Pressing the Ctrl-C combination on the keyboard while a command is executing in the foreground sends which of following signal codes?
Options
- A1 (SIGHUP)
- B2 (SIGINT)
- C3 (SIGQUIT)
- D9 (SIGKILL)
- E15 (SIGTEPM)
How the community answered
(35 responses)- A3% (1)
- B71% (25)
- C3% (1)
- D14% (5)
- E9% (3)
Why each option
Pressing Ctrl-C in a terminal sends signal number 2, SIGINT, to the foreground process, requesting it to interrupt and terminate.
SIGHUP (signal 1) is sent to a process when its controlling terminal is closed or the session leader disconnects, not from Ctrl-C.
SIGINT (signal 2) is the interrupt signal generated by the terminal driver when the user presses Ctrl-C on the keyboard. The kernel delivers this signal to the foreground process group, giving the process an opportunity to catch it, clean up resources, and exit gracefully. This is distinct from a forced kill because a process can install a signal handler to intercept SIGINT.
SIGQUIT (signal 3) is sent by Ctrl-\ and causes the process to terminate and produce a core dump, unlike the Ctrl-C interrupt.
SIGKILL (signal 9) forcefully terminates a process without giving it a chance to catch or handle the signal and is not generated by any keyboard combination.
SIGTERM (signal 15) is the default termination signal sent by the kill command with no explicit signal number and is not triggered by Ctrl-C.
Concept tested: SIGINT signal generated by Ctrl-C keyboard shortcut
Source: https://man7.org/linux/man-pages/man7/signal.7.html
Topics
Community Discussion
No community discussion yet for this question.