From d7d53f439806e684c893cbe977a121b81cc8ad28 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Sun, 30 Oct 2005 19:39:56 +0000 Subject: [PATCH] Do not break some other process's lockfile in "-q" mode, but wait for the other process's exit. svn path=/trunk/; revision=4377 --- NEWS | 2 ++ fetchmail.c | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index b5203875..f9da8853 100644 --- a/NEWS +++ b/NEWS @@ -252,6 +252,8 @@ fetchmail 6.3.0 (not yet released officially): * Exit with error if the lock file cannot be read. Matthias Andree * Exit with error if the lock file cannot be created exclusively, this got broken in a 6.2.6-pre, 6.2.5.2 and older were fine. Matthias Andree +* Do not break some other process's lockfile in "-q" mode, but wait for the + other process's exit. Matthias Andree # INTERNAL CHANGES * Switched to automake. Matthias Andree. diff --git a/fetchmail.c b/fetchmail.c index 3e6d1408..93c5cd8b 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -402,14 +402,23 @@ int main(int argc, char **argv) } else { + int maxwait; + if (outlevel > O_SILENT) fprintf(stderr,GT_("fetchmail: %s fetchmail at %d killed.\n"), bkgd ? GT_("background") : GT_("foreground"), pid); - fm_lock_release(); + /* We used to nuke the other process's lock here, with + * fm_lock_release(), which is broken. The other process + * needs to clear its lock by itself. */ if (quitonly) exit(0); - else - pid = 0; + + /* wait for other process to exit */ + maxwait = 10; /* seconds */ + while (kill(pid, 0) == 0 && --maxwait >= 0) { + sleep(1); + } + pid = 0; } } -- 2.43.2