1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 11:16:16 +02:00

tail: allow multiple PIDs

tail can watch multiple files, but currently only a single writer. It
can be useful to watch files from multiple writers, or even processes
not directly related to the files (e.g. watch log files written by a
server process, for the duration of a test driven by a separate
client).

* src/tail.c (writers_are_dead): New function.
(tail_forever): Use it to wait for writers.
(tail_forever_inotify): As above.
(parse_options): Manage --pid options in an array.
* doc/coreutils.texi: Update documentation.
* tests/tail/pid.sh: Add a variant with two PIDs.
* News: Mention the new feature.
This commit is contained in:
Stephen Kitt
2023-09-18 18:09:29 +02:00
committed by Pádraig Brady
parent 8367b95a13
commit d24a117707
4 changed files with 57 additions and 27 deletions

View File

@@ -3187,9 +3187,10 @@ Size multiplier suffixes are the same as with the @option{-c} option.
@item --pid=@var{pid}
@opindex --pid
When following by name or by descriptor, you may specify the process ID,
@var{pid}, of the sole writer of all @var{file} arguments. Then, shortly
after that process terminates, tail will also terminate. This will
work properly only if the writer and the tailing process are running on
@var{pid}, of one or more (by repeating @option{--pid}) writers of the
@var{file} arguments. Then, shortly after all the identified
processes terminate, tail will also terminate. This will
work properly only if the writers and the tailing process are running on
the same machine. For example, to save the output of a build in a file
and to watch the file grow, if you invoke @command{make} and @command{tail}
like this then the tail process will stop when your build completes.