From: Collin Funk
Subject: bug#80010: timeout echo vs. timeout cat
Date: Sun, 14 Dec 2025 19:08:28 -0800
>...
>In the terminal window with 'strace' running, we can see that 'timeout'
>isn't invoked until after "pipe" is opened after being unblocked:
> $ strace -p 1483195
> strace: Process 1483195 attached
> openat(AT_FDCWD, "pipe", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
> dup2(3, 1) = 1
> close(3) = 0
> execve("/home/collin/.local/bin/timeout", ["timeout", "1", "echo", "foo"],
>0x561e21977ae0 /* 86 vars */) = 0
>I agree that this behavior isn't obvious. :)
Good explanation, but, for completeness, it would have been nice to
finish by providing OP with the (well, "a") workaround, which is to
invoke a shell as the process controlled by "timeout". Something like
(untested):
$ timeout sh -c 'echo foo > pipe'
This sort of thing is a common enough idiom in Unix/Linux scripting.
When passing command lines to programs that invoke programs, you often
have to invoke a shell along the way in order to get the desired
semantics. (O/T) This is also the case in Windows, where you
frequently have to do something like "cmd /c ..." in order for it to
work as expected.
=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.
When responding to my posts, please try to refrain from giving bureaucratic
answers.
If you have nothing useful to say, then just click Next and go on.