Iván Ezequiel Rodriguez <[email protected]> writes:

> When st_size is not usable, truncate opens the --reference operand and
> uses lseek(SEEK_END) to obtain a size.  Opening a FIFO with O_RDONLY
> blocks until a writer appears, so "truncate --reference=fifo file"
> could hang indefinitely.  Use O_NONBLOCK, matching the existing open of
> the output file and the approach taken in df.
>
> Introduced by commit v8.16-49-g9d308df13.
>
> * NEWS: Mention the fix.
> * src/truncate.c (main): Open the reference with O_NONBLOCK.
> * tests/truncate/truncate-fifo.sh: Also cover --reference=FIFO.
>
> Signed-off-by: Iván Ezequiel Rodriguez <[email protected]>
> ---
>  NEWS                            | 3 +++
>  src/truncate.c                  | 3 ++-
>  tests/truncate/truncate-fifo.sh | 8 ++++++++
>  3 files changed, 13 insertions(+), 1 deletion(-)

This looks correct to me. I'll push it later to allow others a chance to
double-check.

Thanks!
Collin



Reply via email to