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...

Reviewed by:	scottl
MFC after:	3 days
This commit is contained in:
John-Mark Gurney 2006-04-11 23:10:02 +00:00
parent 6070eb3f93
commit 4d5e876be3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=157671

View File

@ -175,7 +175,7 @@ pidfile_write(struct pidfh *pfh)
}
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)) {
error = errno;
_pidfile_remove(pfh, 0);
errno = error;