From f4536bcba23c34db1d990a27d73156b024b11f5d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 16 Jun 1999 09:20:06 +0000 Subject: Fix lockfile screwage. svn path=/trunk/; revision=2505 --- NEWS | 3 ++- fetchmail.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 33602ff3..28d97a52 100644 --- a/NEWS +++ b/NEWS @@ -13,8 +13,9 @@ fetchmail-5.0.5 (): * Added Spanish and German descriptions to spec (thanks to Horst von Brand). * Moved MIME decoding earlier to avoid messing with header length after offsets have been calculated. +* Make the .fetchmail_pid lockfile with O_ECL. Duhh... -There are 261 people on fetchmail-friends and 408 on fetchmail-announce. +There are 258 people on fetchmail-friends and 412 on fetchmail-announce. fetchmail-5.0.4 (Fri Jun 11 18:32:58 EDT 1999): * Fixed compilation error on systems without vnsprintf. diff --git a/fetchmail.c b/fetchmail.c index d9ff9258..98428ff6 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -13,6 +13,7 @@ #if defined(HAVE_UNISTD_H) #include #endif +#include #include #include #if defined(HAVE_SYSLOG) @@ -521,11 +522,15 @@ int main (int argc, char **argv) signal(SIGQUIT, termhook); /* here's the exclusion lock */ - if ((lockfp = fopen(lockfile,"w")) != NULL) { - fprintf(lockfp,"%d",getpid()); + if ((st = open(lockfile, O_WRONLY | O_CREAT | O_EXCL, 0666)) != -1) { + sprintf(tmpbuf,"%d", getpid()); + write(st, tmpbuf, strlen(tmpbuf)); if (run.poll_interval) - fprintf(lockfp," %d", run.poll_interval); - fclose(lockfp); + { + sprintf(tmpbuf," %d", run.poll_interval); + write(st, tmpbuf, strlen(tmpbuf)); + } + close(st); #ifdef HAVE_ATEXIT atexit(unlockit); -- cgit v1.2.3