On Feb 7, 2008 5:54 AM, Mahdi A Sbeih <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a script that logs activities to a txt log file. I noticed that
> when deleting the file from another window or shell, the script stops
> writing to the file. I was expecting something like the unix shell,
> which is creating a new file and appending to it.
snip
> After few seconds, and from another terminal, delete the file that was
> created by the script, notice that the script won't stop or error out,
> but in the same time no new file is created.
snip

When you unlink* a file you are telling the filesystem that the name
that is associated with that inode should no longer be used, but the
space is not reclaimed so long as there is still a reference to the
inode.  This reference can be another link created by the link syscall
or an open file handle.  A common trick used by daemons is to open
temporary files in read/write mode and then unlink them.  By doing
this they can ensure that no other process can read or write to the
file.  This is what is happening to you.  What you need to do is open
the file for appending right before each write and close it right
after the write.

* There is no such thing as delete in POSIX filesystems; normally it
doesn't matter, but in this case you need to understand what is really
happening.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to