coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tail: --pid option does not work when input is a FIFO


From: Pádraig Brady
Subject: Re: tail: --pid option does not work when input is a FIFO
Date: Fri, 18 Oct 2024 13:50:26 +0100
User-agent: Mozilla Thunderbird Beta

On 17/10/2024 22:38, Bernhard Voelker wrote:
Hi *,

I noticed that 'tail --pid' does not work when the file to follow is a FIFO.
Shouldn't --pid behave the same regardless whether it's a pipe or not?

# Good case.
$ rm f; touch f  # tail to follow regular file.
$ sleep 5 & timeout 10 tail -f --pid=$! f; echo $?
[3] 1030528
[3]+  Done                    sleep 5
0

# Bad case.
$ rm f; mkfifo f  # tail to follow a FIFO file.
$ sleep 5 & timeout 10 tail -f --pid=$! f; echo $?
[3] 1030559
[3]+  Done                    sleep 5
124

Looking at strace output, one can see that kill() is only invoked once in the 
FIFO case.

FWIW: it doesn't make a difference whether one uses -f or -F, whether the
monitored file is written to by another process or stays empty, or whether one
tries with the  --sleep-interval option.

In my testing the initial open() of the fifo blocks,
before the -f loops are processed.
If the monitored file was written by another process,
this _does_ unblock things for me, and --pid is processed.

The attached patch avoids the blocking behavior with fifos,
and thus honors the --pid checking in parallel (and passes all tests).

However I've only thought about this for a couple of minutes,
so need to consider all the implications.

cheers,
Pádraig

Attachment: tail-fifo-block.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]