From 36c5075506895b66e783b76355013de66823fb3d Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Sat, 18 Dec 2010 16:07:57 +0100 Subject: Accept more options with a running daemon. (Cherry-picked from master's 1a92b2909610096a11d26f7a7317d32819354be3.) --- fetchmail.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'fetchmail.c') diff --git a/fetchmail.c b/fetchmail.c index 22d492ae..8b0a5c3d 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -159,6 +159,8 @@ int main(int argc, char **argv) { int bkgd = FALSE; int implicitmode = FALSE; + flag safewithbg = FALSE; /** if parsed options are compatible with a + fetchmail copy running in the background */ struct query *ctl; netrc_entry *netrc_list; char *netrc_file, *tmpbuf; @@ -202,7 +204,7 @@ int main(int argc, char **argv) #define IDFILE_NAME ".fetchids" run.idfile = prependdir (IDFILE_NAME, fmhome); - + outlevel = O_NORMAL; /* @@ -226,7 +228,7 @@ int main(int argc, char **argv) { int i; - i = parsecmdline(argc, argv, &cmd_run, &cmd_opts); + i = parsecmdline(argc, argv, &cmd_run, &cmd_opts, &safewithbg); if (i < 0) exit(PS_SYNTAX); @@ -541,17 +543,23 @@ int main(int argc, char **argv) else if (getpid() == pid) /* this test enables re-execing on a changed rcfile */ fm_lock_assert(); - else if (argc > 1) + else if (argc > 1 && !safewithbg) { fprintf(stderr, GT_("fetchmail: can't accept options while a background fetchmail is running.\n")); + { + int i; + fprintf(stderr, "argc = %d, arg list:\n", argc); + for (i = 1; i < argc; i++) fprintf(stderr, "arg %d = \"%s\"\n", i, argv[i]); + } return(PS_EXCLUDE); } else if (kill(pid, SIGUSR1) == 0) { - fprintf(stderr, - GT_("fetchmail: background fetchmail at %ld awakened.\n"), - (long)pid); + if (outlevel > O_SILENT) + fprintf(stderr, + GT_("fetchmail: background fetchmail at %ld awakened.\n"), + (long)pid); return(0); } else -- cgit v1.2.3