Subject: | Bug with ignore_nonexistant |
If you specify ignore_nonexistant and the script is started without the
file being present; when the file gets created the first line (or
perhaps first block) is skipped. This is due to the tail option
defaulting to 0; which is what we want if the file exists when the
script is started. I suggest that if the file does not exist when the
first read occurs, you want to set tail to -1 (or the value of
reset_tail). I believe the following patch does this:
unless (open($newhandle,"<$newname")) {
if ($object->{'ignore_nonexistant'}) {
# If we have an oldhandle, leave endpos and curpos to what they
# were, since oldhandle will still be the "current" handle
elsewhere,
# eg, checkpending. This also allows tailing a file which is
removed
# but still being written to.
if (!$oldhandle) {
$object->{'endpos'}=0;
$object->{'curpos'}=0;
# The file didn't exist and this was the first time.
When the
# file is created we want to spit out the whole of the file.
$object->{tail} = $object->{reset_tail};
}
return;
}