On 02/04/2021 14:22, Patrick Reader wrote:
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?

That's exactly correct.
timeout is trying to be as transparent as possible.

cheers,
Pádraig

Reply via email to