diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1999-06-16 09:20:06 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1999-06-16 09:20:06 +0000 |
commit | f4536bcba23c34db1d990a27d73156b024b11f5d (patch) | |
tree | 0627d17f9e2377ffdb03a7d2f2377076d94940c9 /fetchmail.c | |
parent | 886e698c78b233494172660918a6d0d0e95ffa72 (diff) | |
download | fetchmail-f4536bcba23c34db1d990a27d73156b024b11f5d.tar.gz fetchmail-f4536bcba23c34db1d990a27d73156b024b11f5d.tar.bz2 fetchmail-f4536bcba23c34db1d990a27d73156b024b11f5d.zip |
Fix lockfile screwage.
svn path=/trunk/; revision=2505
Diffstat (limited to 'fetchmail.c')
-rw-r--r-- | fetchmail.c | 13 |
1 files changed, 9 insertions, 4 deletions
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 <unistd.h> #endif +#include <fcntl.h> #include <string.h> #include <signal.h> #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); |