Module Name:    src
Committed By:   christos
Date:           Fri Oct  9 17:51:27 UTC 2015

Modified Files:
        src/usr.bin/tail: forward.c

Log Message:
PR/50322: Timo Buhrmester: tail -F <file> misbehaves with stdin closed
Compare fp with stdin not fileno(fp) with STDIN_FILENO, because if tail
is called with 0 closed, then we are not going to be setting event filters
for the file because we'll erroneously think it is stdin.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/tail/forward.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tail/forward.c
diff -u src/usr.bin/tail/forward.c:1.32 src/usr.bin/tail/forward.c:1.33
--- src/usr.bin/tail/forward.c:1.32	Fri Oct 18 16:47:07 2013
+++ src/usr.bin/tail/forward.c	Fri Oct  9 13:51:26 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: forward.c,v 1.32 2013/10/18 20:47:07 christos Exp $	*/
+/*	$NetBSD: forward.c,v 1.33 2015/10/09 17:51:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)forward.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: forward.c,v 1.32 2013/10/18 20:47:07 christos Exp $");
+__RCSID("$NetBSD: forward.c,v 1.33 2015/10/09 17:51:26 christos Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -198,7 +198,7 @@ forward(FILE *fp, enum STYLE style, off_
 			n = 0;
 
 			memset(ev, 0, sizeof(ev));
-			if (fflag == 2 && fileno(fp) != STDIN_FILENO) {
+			if (fflag == 2 && fp != stdin) {
 				EV_SET(&ev[n], fileno(fp), EVFILT_VNODE,
 				    EV_ADD | EV_ENABLE | EV_CLEAR,
 				    NOTE_DELETE | NOTE_RENAME, 0, 0);
@@ -240,7 +240,7 @@ forward(FILE *fp, enum STYLE style, off_
 			 */
                 	(void) sleep(1);
 
-			if (fflag == 2 && fileno(fp) != STDIN_FILENO &&
+			if (fflag == 2 && fp != stdin &&
 			    stat(fname, &statbuf) != -1) {
 				if (statbuf.st_ino != sbp->st_ino ||
 				    statbuf.st_dev != sbp->st_dev ||

Reply via email to