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:
parent
6070eb3f93
commit
4d5e876be3
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user