From ca47081c5bc7759a88eaf9eebf3ae163c0aed2f9 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 31 Jul 1999 09:21:32 +0000 Subject: [PATCH] (tail_forever): Don't call kill if pid is 0. Detect when `writer_is_dead' also when the writer is some other user. From Karl Heuer. (parse_options): Warn if --pid=PID is used without -f. --- src/tail.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tail.c b/src/tail.c index b8109dd..e6f9b42 100644 --- a/src/tail.c +++ b/src/tail.c @@ -922,7 +922,12 @@ tail_forever (struct File_spec *f, int nfiles) /* Once the writer is dead, read the files once more to avoid a race condition. */ - writer_is_dead = (kill (pid, 0) != 0); + writer_is_dead = (pid != 0 + && kill (pid, 0) != 0 + /* Handle the case in which you cannot send a + signal to the writer, so kill fails and sets + errno to EPERM. */ + && errno != EPERM); } } } @@ -1426,6 +1431,10 @@ parse_options (int argc, char **argv, if (reopen_inaccessible_files && follow_mode != Follow_name) error (0, 0, _("warning: --retry is useful only when following by name")); + + if (pid && !forever) + error (0, 0, + _("warning: PID ignored; --pid=PID is useful only when following")); } int -- 2.7.4