MiniDevil
As beautiful as a shell
The shell switches between 4 signal configurations depending on context:
| Mode | SIGINT | SIGQUIT | Active while… | Setup |
|---|---|---|---|---|
| interactive | interactive_sigint_handler | SIG_IGN | waiting on readline() | setup_interactive_signals() |
| exec | SIG_IGN | SIG_IGN | parent waiting for child | setup_execution_signals() |
| child | SIG_DFL | SIG_DFL | after fork(), before execve() | reset_child_signals() |
| heredoc | heredoc_sigint_handler | SIG_IGN | heredoc readline() loop | setup_heredoc_signals() |
Note: interactive uses SA_RESTART but heredoc does not.
g_signal == SIGINT set exit_status = 130 and clearg_signal == SIGINT return immediately (interrupted)Idle prompt:
g_signal == SIGINT and sets exit_status = 130.During external command:
DUring heredoc:
g_signal == SIGINT detected -> read_heredoc_lines() returns 1 (interrupted).