From 9dc0b8bd674f71f8ee422b037dc409f2dd4f9487 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Tue, 14 Mar 2006 09:10:20 +0000 Subject: merge Mirek's fetchmail-signed.patch svn path=/branches/BRANCH_6-3/; revision=4734 --- lock.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lock.c') diff --git a/lock.c b/lock.c index 5d41c587..89f767da 100644 --- a/lock.c +++ b/lock.c @@ -118,12 +118,18 @@ void lock_or_die(void) int e = 0; if ((fd = open(lockfile, O_WRONLY|O_CREAT|O_EXCL, 0666)) != -1) { + ssize_t wr; + snprintf(tmpbuf, sizeof(tmpbuf), "%ld\n", (long)getpid()); - if (write(fd, tmpbuf, strlen(tmpbuf)) < strlen(tmpbuf)) e = 1; + wr = write(fd, tmpbuf, strlen(tmpbuf)); + if (wr == -1 || (size_t)wr != strlen(tmpbuf)) + e = 1; if (run.poll_interval) { snprintf(tmpbuf, sizeof(tmpbuf), "%d\n", run.poll_interval); - if (write(fd, tmpbuf, strlen(tmpbuf)) < strlen(tmpbuf)) e = 1; + wr = write(fd, tmpbuf, strlen(tmpbuf)); + if (wr == -1 || (size_t)wr != strlen(tmpbuf)) + e = 1; } if (fsync(fd)) e = 1; if (close(fd)) e = 1; -- cgit v1.2.3