Weird behavior in logrotate

From: Scott Simpson (ssimpson_at_visionsolutions.com)
Date: 07/31/04


Date: Fri, 30 Jul 2004 17:11:30 -0700

We are running logrotate with the "copytruncate" option. This option
truncates the file in place without changing the inode and copies the
contents to a backup file. Also, we have a Java program that is writing to
the file at the same time (with its file pointer at the 300K mark say). When
the truncate occurs, the file length shows as zero, but when the Java
program writes to the file after the truncate, I get 300K of nulls and then
the log file text from the Java program.

As I recall, other Unixes actually truncated the file and processes with
open file pointers would start back at the end of the file. Am I correct?
How would I get around this in Linux? I can't access the file pointer in the
Java process from logrotate.