On Tue, Apr 11, 2006 at 11:10:02PM +0000, John-Mark Gurney wrote:
+> jmg 2006-04-11 23:10:02 UTC
+>
+> FreeBSD src repository
+>
+> Modified files:
+> lib/libutil pidfile.c
+> Log:
+> 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...
[...]
+> snprintf(pidstr, sizeof(pidstr), "%u", getpid());
+> - if (write(fd, pidstr, strlen(pidstr)) != (ssize_t)strlen(pidstr)) {
+> + if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) {Multiple pidfile_write()s from the same process? If not, then we must truncate the file before writting the PID. Imagine a situation, where PID 10000 is written first and then we overwrite it with 9999. The result will be 99990. -- Pawel Jakub Dawidek http://www.wheel.pl [EMAIL PROTECTED] http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am!
pgpXYBsySDZGW.pgp
Description: PGP signature
