Quote:> Dear All,
> My process creates a file (log) under Solaris 8.
> Then performs C-language fputs'es and fflush'es.
> But when I delete this file from e.g. file manager, later fputs and fflush
> do not return errors (EOF) and process does not know that insertions
> to the log are not executed in fact.
That's because they are executed.
> 1. Is any way to block deleting when the file is opened and used by my
> process ?
No. Set the permissions if you don't want it to be deleted.
Quote:> 2. Why an error is not returned ?
Because the file continues to exist on the disk. The only thing that
occured was that the directory entry was removed. When you close the
file, that will cause the file to be removed.
Until the file is closed, the process with it open could seek() to the
beginning of the file and read the log. All the data is there.
Quote:> 3. How can my process notice a physical lack of the log after outisde
> deletion (in most efficent way) ?
Attempt to fstat() the file descriptor. If the link count has gone down
to 0, then the file does not exist in the directory any longer.
Better would be to set the permissions so that the file cannot be
deleted. Most logging programs do not bother trying to make sure the
logs are not deleted. That is the job of the sysadmins...
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< How are you gentlemen!! Take off every '.SIG'!! >