]> Pileus Git - ~andy/fetchmail/commitdiff
If the lockfile ends before the process ID, treat it as stale and unlink it.
authorMatthias Andree <matthias.andree@gmx.de>
Tue, 4 Jul 2006 10:01:51 +0000 (10:01 -0000)
committerMatthias Andree <matthias.andree@gmx.de>
Tue, 4 Jul 2006 10:01:51 +0000 (10:01 -0000)
Reported by Justin Pryzby, Debian Bug #376603.

svn path=/branches/BRANCH_6-3/; revision=4862

NEWS
lock.c

diff --git a/NEWS b/NEWS
index 40561dfe7816365a1a6cdf938aa358bcff44288e..fc00b061bf3b3890f15c379ea434105092fb93c7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -87,6 +87,8 @@ fetchmail 6.3.5 (not yet released):
   service lookup. Found by Uli Zappe.
 * When looking up ports for a service, only look up TCP ports.
 * Avoid compiling empty files, to avoid diagnostics from strict compilers.
+* If the lockfile ends before the process ID, treat it as stale and unlink it.
+  Reported by Justin Pryzby, Debian Bug #376603.
 
 # CHANGES:
 * Rename all fetchmail-internal lock_* functions to fm_lock_*. Obsoletes
diff --git a/lock.c b/lock.c
index 39351be1f4bac84f98800539f841be48d18fdcb2..c0290393147b9363ea2bb5533946940efbc485bc 100644 (file)
--- a/lock.c
+++ b/lock.c
@@ -85,20 +85,21 @@ int fm_lock_state(void)
        if (ferror(lockfp)) {
            fprintf(stderr, GT_("fetchmail: error reading lockfile \"%s\": %s\n"),
                    lockfile, strerror(errno));
+           fclose(lockfp); /* not checking should be safe, file mode was "r" */
            exit(PS_EXCLUDE);
        }
+       fclose(lockfp); /* not checking should be safe, file mode was "r" */
 
-       if (args == 0 || kill(pid, 0) == -1) {
+       if (args == EOF || args == 0 || kill(pid, 0) == -1) {
            pid = 0;
+
+           fprintf(stderr,GT_("fetchmail: removing stale lockfile\n"));
            if (unlink(lockfile)) {
               if (errno != ENOENT) {
                   perror(lockfile);
               }
-           } else {
-               fprintf(stderr,GT_("fetchmail: removing stale lockfile\n"));
            }
        }
-       fclose(lockfp); /* not checking should be safe, file mode was "r" */
     } else {
        pid = 0;
        if (errno != ENOENT) {