From d7d53f439806e684c893cbe977a121b81cc8ad28 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Sun, 30 Oct 2005 19:39:56 +0000 Subject: Do not break some other process's lockfile in "-q" mode, but wait for the other process's exit. svn path=/trunk/; revision=4377 --- fetchmail.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'fetchmail.c') 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; } } -- cgit v1.2.3