Lines 106-111
Link Here
|
106 |
dev_t dev; |
106 |
dev_t dev; |
107 |
ino_t ino; |
107 |
ino_t ino; |
108 |
|
108 |
|
|
|
109 |
/* Whether this file is a FIFO */ |
110 |
int fifo; |
111 |
|
112 |
/* Whether this file is a FIFO and we received eof last time we read from it |
113 |
* */ |
114 |
int read_eof; |
115 |
|
109 |
/* The specified name initially referred to a directory or some other |
116 |
/* The specified name initially referred to a directory or some other |
110 |
type for which tail isn't meaningful. Unlike for a permission problem |
117 |
type for which tail isn't meaningful. Unlike for a permission problem |
111 |
(tailable, below) once this is set, the name is not checked ever again. */ |
118 |
(tailable, below) once this is set, the name is not checked ever again. */ |
Lines 971-976
Link Here
|
971 |
{ |
978 |
{ |
972 |
int last; |
979 |
int last; |
973 |
int writer_is_dead = 0; |
980 |
int writer_is_dead = 0; |
|
|
981 |
int fifo_read = 0; |
974 |
|
982 |
|
975 |
last = nfiles - 1; |
983 |
last = nfiles - 1; |
976 |
|
984 |
|
Lines 978-988
Link Here
|
978 |
{ |
986 |
{ |
979 |
int i; |
987 |
int i; |
980 |
int any_changed; |
988 |
int any_changed; |
|
|
989 |
int skip_fifo; |
981 |
|
990 |
|
982 |
any_changed = 0; |
991 |
any_changed = 0; |
|
|
992 |
|
993 |
skip_fifo = fifo_read; |
994 |
fifo_read = 0; |
995 |
|
983 |
for (i = 0; i < nfiles; i++) |
996 |
for (i = 0; i < nfiles; i++) |
984 |
{ |
997 |
{ |
985 |
struct stat stats; |
998 |
struct stat stats; |
|
|
999 |
int bytes_read; |
1000 |
|
986 |
|
1001 |
|
987 |
if (f[i].ignore) |
1002 |
if (f[i].ignore) |
988 |
continue; |
1003 |
continue; |
Lines 993-1029
Link Here
|
993 |
continue; |
1008 |
continue; |
994 |
} |
1009 |
} |
995 |
|
1010 |
|
996 |
if (fstat (f[i].fd, &stats) < 0) |
1011 |
if (f[i].fifo) |
997 |
{ |
1012 |
{ |
998 |
f[i].fd = -1; |
1013 |
if (f[i].read_eof == 1 || skip_fifo) |
999 |
f[i].errnum = errno; |
1014 |
{ |
1000 |
error (0, errno, "%s", pretty_name (&f[i])); |
1015 |
f[i].read_eof = 0; |
1001 |
continue; |
1016 |
continue; |
1002 |
} |
1017 |
} |
1003 |
|
1018 |
} |
1004 |
if (stats.st_size == f[i].size) |
1019 |
else |
1005 |
{ |
1020 |
{ |
1006 |
f[i].n_consecutive_size_changes = 0; |
1021 |
if (fstat (f[i].fd, &stats) < 0) |
1007 |
if ((max_n_unchanged_stats_between_opens |
1022 |
{ |
1008 |
<= f[i].n_unchanged_stats++) |
1023 |
f[i].fd = -1; |
1009 |
&& follow_mode == Follow_name) |
1024 |
f[i].errnum = errno; |
1010 |
{ |
1025 |
error (0, errno, "%s", pretty_name (&f[i])); |
1011 |
recheck (&f[i]); |
1026 |
continue; |
1012 |
f[i].n_unchanged_stats = 0; |
1027 |
} |
1013 |
} |
1028 |
|
1014 |
continue; |
1029 |
if (stats.st_size == f[i].size) |
1015 |
} |
1030 |
{ |
1016 |
|
1031 |
f[i].n_consecutive_size_changes = 0; |
1017 |
/* Ensure that a file that's unlinked or moved aside, yet always |
1032 |
if ((max_n_unchanged_stats_between_opens |
1018 |
growing will be recognized as having been renamed. */ |
1033 |
<= f[i].n_unchanged_stats++) |
1019 |
if ((max_n_consecutive_size_changes_between_opens |
1034 |
&& follow_mode == Follow_name) |
1020 |
<= f[i].n_consecutive_size_changes++) |
1035 |
{ |
1021 |
&& follow_mode == Follow_name) |
1036 |
recheck (&f[i]); |
1022 |
{ |
1037 |
f[i].n_unchanged_stats = 0; |
1023 |
f[i].n_consecutive_size_changes = 0; |
1038 |
} |
1024 |
recheck (&f[i]); |
1039 |
continue; |
1025 |
continue; |
1040 |
} |
1026 |
} |
1041 |
|
|
|
1042 |
/* Ensure that a file that's unlinked or moved aside, yet always |
1043 |
growing will be recognized as having been renamed. */ |
1044 |
if ((max_n_consecutive_size_changes_between_opens |
1045 |
<= f[i].n_consecutive_size_changes++) |
1046 |
&& follow_mode == Follow_name) |
1047 |
{ |
1048 |
f[i].n_consecutive_size_changes = 0; |
1049 |
recheck (&f[i]); |
1050 |
continue; |
1051 |
} |
1052 |
|
1053 |
if (stats.st_size < f[i].size) |
1054 |
{ |
1055 |
error (0, 0, _("%s: file truncated"), pretty_name (&f[i])); |
1056 |
last = i; |
1057 |
xlseek (f[i].fd, (off_t) stats.st_size, SEEK_SET, |
1058 |
pretty_name (&f[i])); |
1059 |
f[i].size = stats.st_size; |
1060 |
continue; |
1061 |
} |
1062 |
} |
1027 |
|
1063 |
|
1028 |
/* This file has changed size. Print out what we can, and |
1064 |
/* This file has changed size. Print out what we can, and |
1029 |
then keep looping. */ |
1065 |
then keep looping. */ |
Lines 1033-1047
Link Here
|
1033 |
/* reset counter */ |
1069 |
/* reset counter */ |
1034 |
f[i].n_unchanged_stats = 0; |
1070 |
f[i].n_unchanged_stats = 0; |
1035 |
|
1071 |
|
1036 |
if (stats.st_size < f[i].size) |
|
|
1037 |
{ |
1038 |
error (0, 0, _("%s: file truncated"), pretty_name (&f[i])); |
1039 |
last = i; |
1040 |
xlseek (f[i].fd, (off_t) stats.st_size, SEEK_SET, |
1041 |
pretty_name (&f[i])); |
1042 |
f[i].size = stats.st_size; |
1043 |
continue; |
1044 |
} |
1045 |
|
1072 |
|
1046 |
if (i != last) |
1073 |
if (i != last) |
1047 |
{ |
1074 |
{ |
Lines 1049-1056
Link Here
|
1049 |
write_header (pretty_name (&f[i])); |
1076 |
write_header (pretty_name (&f[i])); |
1050 |
last = i; |
1077 |
last = i; |
1051 |
} |
1078 |
} |
1052 |
f[i].size += dump_remainder (pretty_name (&f[i]), f[i].fd, |
1079 |
bytes_read = dump_remainder (pretty_name (&f[i]), f[i].fd, |
1053 |
COPY_TO_EOF); |
1080 |
COPY_TO_EOF); |
|
|
1081 |
if (f[i].fifo == 1) |
1082 |
{ |
1083 |
if (bytes_read == 0) |
1084 |
{ |
1085 |
f[i].read_eof = 1; |
1086 |
} |
1087 |
else |
1088 |
{ |
1089 |
fifo_read = 1; |
1090 |
} |
1091 |
} |
1092 |
else |
1093 |
{ |
1094 |
f[i].size += bytes_read; |
1095 |
} |
1054 |
} |
1096 |
} |
1055 |
|
1097 |
|
1056 |
if (n_live_files (f, nfiles) == 0 && ! reopen_inaccessible_files) |
1098 |
if (n_live_files (f, nfiles) == 0 && ! reopen_inaccessible_files) |
Lines 1250-1256
Link Here
|
1250 |
} |
1292 |
} |
1251 |
else |
1293 |
else |
1252 |
{ |
1294 |
{ |
1253 |
fd = open (f->name, O_RDONLY); |
1295 |
fd = open (f->name, O_RDONLY | O_NONBLOCK); |
1254 |
} |
1296 |
} |
1255 |
|
1297 |
|
1256 |
f->tailable = !(reopen_inaccessible_files && fd == -1); |
1298 |
f->tailable = !(reopen_inaccessible_files && fd == -1); |
Lines 1321-1326
Link Here
|
1321 |
f->n_unchanged_stats = 0; |
1363 |
f->n_unchanged_stats = 0; |
1322 |
f->n_consecutive_size_changes = 0; |
1364 |
f->n_consecutive_size_changes = 0; |
1323 |
f->ignore = 0; |
1365 |
f->ignore = 0; |
|
|
1366 |
if (S_ISFIFO (stats.st_mode)) |
1367 |
{ |
1368 |
f->fifo = 1; |
1369 |
} |
1370 |
else |
1371 |
{ |
1372 |
f->fifo = 0; |
1373 |
} |
1324 |
} |
1374 |
} |
1325 |
} |
1375 |
} |
1326 |
else |
1376 |
else |