in reply to Re^10: Print inside SIGNALS
in thread Print inside SIGNALS
Funny discussion. But I think both of you are correct.
When blocking the program with <>, is the alarm signal block executed when I send SIGINT? On Unix/Linux: In case waited long enough for the alarm timeout to happen: Yes, always.
So why is it not printed? A buffering issue? Yes and no.
Yes and no?
Yes, data may be stuck in the buffer when using STDOUT (e.g. it did not have a "\n" when that was the flush condition). But that is not the reason why it is not printed.
Sigh..., so why is it not printed then?
Because the program received a SIGINT and terminated because the program does not have a handler. Remind that the intention of SIGINT is to provide a mechanism for an orderly, graceful shutdown. But the program doesn't have that so it has ended prematurely and the buffer is not flushed at normal program end.
But why is the line ending with a '\n' printed then after sending the SIGINT? Because the line was already transferred to the operating system buffer. But that buffer was only flushed after the blocking <> was terminated.
This is how I think it works and why I think you are both right. However not entirely explained correctly maybe.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^12: Print inside SIGNALS
by haukex (Archbishop) on Jul 19, 2018 at 17:34 UTC | |
by Veltro (Hermit) on Jul 19, 2018 at 20:09 UTC | |
by haukex (Archbishop) on Jul 19, 2018 at 21:17 UTC | |
by Veltro (Hermit) on Jul 19, 2018 at 21:46 UTC | |
by haukex (Archbishop) on Jul 19, 2018 at 22:51 UTC | |
| |
by ikegami (Patriarch) on Jul 20, 2018 at 18:48 UTC | |
by haukex (Archbishop) on Jul 20, 2018 at 19:02 UTC | |
| |
by haukex (Archbishop) on Jul 20, 2018 at 18:56 UTC | |
|
Re^12: Print inside SIGNALS
by ikegami (Patriarch) on Jul 20, 2018 at 18:44 UTC | |
by haukex (Archbishop) on Jul 20, 2018 at 19:25 UTC | |
by kcott (Archbishop) on Jul 20, 2018 at 20:44 UTC | |
by haukex (Archbishop) on Jul 20, 2018 at 20:48 UTC | |
by pryrt (Abbot) on Jul 20, 2018 at 19:52 UTC | |
by haukex (Archbishop) on Jul 20, 2018 at 20:28 UTC | |
by Veltro (Hermit) on Jul 20, 2018 at 20:00 UTC | |
by haukex (Archbishop) on Jul 20, 2018 at 20:37 UTC | |
by Veltro (Hermit) on Jul 20, 2018 at 21:26 UTC |