Subject: bug#54681: timeout: Program called by timeout cannot interact with tty stdin when timeout is called by exec()

From: Andreas Schwab <[email-masked]>
Date: Sat, 02 Apr 2022 14:21:14 +0200

On Apr 02 2022, Zhaofeng Yang wrote:

> A simplest example is `timeout 10 timeout 5 cat`. cat cannot read input
> from tty stdin.

That's because timeout creates a new process group by default.  The
outer timeout instance already runs in its own process group curtesy of
the parent shell (and thus remains in that group), but for the inner
instance the process group no longer matches the terminal process group,
and thus the children cannot read from the TTY.  You can use timeout
--foreground to avoid that.

$ timeout 10 timeout --foreground 5 cat

-- 
Andreas Schwab, [email-masked]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."