Following a file, or cloning tail
Cameron Laird
claird at starbase.neosoft.com
Fri Jun 30 08:16:20 EDT 2000
In article <8F62C20E2gmcmhypernetcom at 199.171.54.154>,
Gordon McMillan <gmcm at hypernet.com> wrote:
.
.
.
>The whole inode thing in that code is because it is a common Linux idiom to
>rely on the fact that once a process has opened a file, said file can be
>deleted by another process without the reading process noticing.
>
>This idiom is completely impossible on Windows, so there's no sense in
>checking whether a new file with the same name has now been created.
>
>So what'll it be - a portable version that's useless on Linux, or one that
>spends half it's time checking for something that can't occur on Windows
><wink>?
>
>on-Windows-once-you've-grabbed-the-tail-
> you've-got-the-whole-damn-dog-ly y'rs
>
>- Gordon (who never uses popen on Windows anyway)
It's a good question.
Is tail(1) in POSIX? I'm out of copies of POSIX documentation
again ...
It's never been a difficult question for me. I've ended up
coding different tail functions (methods) for different pro-
jects. Am I committing redundancy in my coding? Barely,
and at a level with which I'm comfortable. The general cat-
egory here is, "ambiguously defined stuff where the ideas
are so clear it's easier recoding them than trying to merge
conflicting requirements/definitions."
I most often need such a tail for log-scraping, and part of
my tail implementations generally is *not* to do what you
describe, but to stop reading the mv-ed i-node and pick up
with a newly-created file (a log, in my case). This illu-
strates the ambiguity in tail's semantics. I repeat: I
resolve the ambiguity by my knowledge of requirements spe-
cific to a project.
You and I might have a slight vocabulary clash. My code
often involves tests of os.name. I think of the results
as "a portable version", without embarrassment. Perhaps
your habit is to regard the same as *not* "pure" Python,
and correspondingly "importable".
--
Cameron Laird <claird at NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
More information about the Python-list
mailing list