From 4d5e876be3861bf6335934d09858bd3c5347e08d Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Tue, 11 Apr 2006 23:10:02 +0000 Subject: [PATCH] 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 --- lib/libutil/pidfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c index 0b8ade1be88..cf7441e0d10 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;