cvs commit: src/lib/libutil pidfile.c
Colin Percival
cperciva at freebsd.org
Wed Apr 12 07:31:28 UTC 2006
Pawel Jakub Dawidek wrote:
> On Tue, Apr 11, 2006 at 11:10:02PM +0000, John-Mark Gurney wrote:
> +> use pwrite to always write at the begining of the file.. If multiple calls
> +> to pidfile_write happen, the pidfile will have nul characters prepended
> +> due to the cached file descriptor offset...
>
> Multiple pidfile_write()s from the same process? If not, then we must
> truncate the file before writting the PID.
We already do -- there's a call to ftruncate(fd, 0) a few lines earlier.
> Imagine a situation, where PID 10000 is written first and then we
> overwrite it with 9999. The result will be 99990.
The only way this can happen is if two different processes call
pidfile_write simultaneously and both ftruncate calls complete
before either pwrite call starts; I don't think this is really
worth worrying about.
Colin Percival
More information about the cvs-src
mailing list