Friday, September 16, 2005

process can not be stopped. And it keeps the file always opened

mp123 <tmp...@menta.net> wrote:
> Hello all,

> In a real time system, mission critical, there are the following
> problem:

> One process is writting a file with "log" information (now useless).
> The
> process can not be stopped. And it keeps the file always opened for
> writting.

It depends how the file was opened by the running process.

If the file was opened with the O_APPEND flag, you can safely truncate
the file:

cp /dev/null /some/log/file

If you do above on files which will be written to without the O_APPEND flag
used on open(), further log writes will write at the end of the old offset.
In this case you end up with a sparse file empty (null bytes) in the first
few megabytes and the real log messages somewhere behind.

0 Comments:

Post a Comment

<< Home