fetchmail-friends
[Top] [All Lists]

[fetchmail] [PATCH] daemon restart

2003-08-07 22:50:40
fetchmail kills itself in daemon mode if it has been invoked with -q
when the rcfile is modified.

$ fetchmail -q -d 300 -f rcfile
$ touch rcfile
$ fetchmail

Here, the awakened fetchmail finds that the rcfile is modified,
reexecutes itself, and then kills itself in quitmode.

This patch should fix the problem:

=======================================================================
diff -Naur fetchmail-6.2.3.orig/fetchmail.c fetchmail-6.2.3/fetchmail.c
--- fetchmail-6.2.3.orig/fetchmail.c    2003-07-17 06:33:20.000000000 +0530
+++ fetchmail-6.2.3/fetchmail.c 2003-08-07 14:08:31.000000000 +0530
@@ -368,6 +368,15 @@
            if (argc == 2)
                exit(PS_EXCLUDE);
        }
+       else if (getpid() == pid)
+       {
+           /* this test enables re-execing on a changed rcfile */
+           if (argc == 2)
+           {
+               fprintf(stderr,GT_("fetchmail: no other fetchmail is 
running\n"));
+               exit(PS_EXCLUDE);
+           }
+       }
        else if (kill(pid, SIGTERM) < 0)
        {
            fprintf(stderr,GT_("fetchmail: error killing %s fetchmail at %d; 
bailing out.\n"),
diff -Naur fetchmail-6.2.3.orig/lock.c fetchmail-6.2.3/lock.c
--- fetchmail-6.2.3.orig/lock.c 2003-07-17 06:33:22.000000000 +0530
+++ fetchmail-6.2.3/lock.c      2003-08-07 14:09:00.000000000 +0530
@@ -77,7 +77,7 @@
     {
        bkgd = (fscanf(lockfp, "%d %d", &pid, &st) == 2);
 
-       if (kill(pid, 0) == -1) {
+       if (pid == 0 || kill(pid, 0) == -1) {
            fprintf(stderr,GT_("fetchmail: removing stale lockfile\n"));
            pid = 0;
            unlink(lockfile);
=======================================================================

-- 
Sunil Shetye.

<Prev in Thread] Current Thread [Next in Thread>