I was reading the source code for timeout
(https://git.savannah.gnu.org/cgit/coreutils.git/tree/src/timeout.c#n589
or
https://github.com/coreutils/coreutils/blob/master/src/timeout.c#L589),
and I saw this code:
> if (!timed_out && disable_core_dumps())
> {
> /* exit with the signal flag set. */
> signal(sig, SIG_DFL);
> unblock_signal(sig);
> raise(sig);
> }
(starting on line 589, as of commit
6c1723ec317efb787d70d40c55397d43846bcd38)
This is what I understand of this section: if the process was signalled,
but not because it timed out, then raise the signal so that timeout's
parent can observe that it exited due to a signal. We disable core dumps
and check that that was successful to ensure that timeout won't dump its
own core because of raising the signal.
Is this correct? I want to understand more about how timeout works,
because I'm looking to implement a similar mechanism in one of my own
projects and I want to be sure I know what the original code does before
I go modifying it.
Thanks,
Patrick