suspected bug in timeout command

Laurent Bercot ska-dietlibc at skarnet.org
Sat Feb 12 23:12:09 UTC 2022


>/* We want to create a grandchild which will watch
>  * and kill the grandparent. Other methods:
>  * making parent watch child disrupts parent<->child link
>  * (example: "tcpsvd 0.0.0.0 1234 timeout service_prog" -
>  * it's better if service_prog is a child of tcpsvd!),
>  * making child watch parent results in programs having
>  * unexpected children.    */
>
>I don't follow this reasoning.  Does "disrupts the parent<->child link" just about sending signals?  If the timeout app relays all signals from itself to the child, what remaining problems would exist?

  Yeah, that's clearly a misdesign.
  Keeping the same pid for the end of a Bernstein chain whenever possible
is a good idea, so the intention is good - but it's only possible when
the child is *entirely transparent* wrt control flow. It's a good
model, for instance, for ssh-agent, or for a data processor such as a
TLS tunnel (that's how s6-tlsd operates); but here, since the child
actually impacts control (it sends a signal to the parent on timeout)
it's just not applicable - and this thread illustrates exactly why.

  To really fix the bug, timeout should be rewritten, and run as the
parent, and possibly forward signals to the child.

--
  Laurent



More information about the busybox mailing list