diff options
author | jmg <jmg@FreeBSD.org> | 2006-04-11 23:10:02 +0000 |
---|---|---|
committer | jmg <jmg@FreeBSD.org> | 2006-04-11 23:10:02 +0000 |
commit | a2a4e2db32ae5047795e7c89277940531c760bf3 (patch) | |
tree | 321e33f658af5fd35fe071c57f623c015382323e /lib/libutil | |
parent | 8ecd1bb434632b0dfe8e87337950dea74c4539d0 (diff) | |
download | FreeBSD-src-a2a4e2db32ae5047795e7c89277940531c760bf3.zip FreeBSD-src-a2a4e2db32ae5047795e7c89277940531c760bf3.tar.gz |
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
Diffstat (limited to 'lib/libutil')
-rw-r--r-- | lib/libutil/pidfile.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c index 0b8ade1..cf7441e 100644 --- a/lib/libutil/pidfile.c +++ b/lib/libutil/pidfile.c @@ -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; |