From c80d3c6b9cde8128a702b13215fd5c1c60d54103 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Aug 2002 18:47:09 +0000 Subject: Refactor so we can use idle.c in the cookbook. svn path=/trunk/; revision=3688 --- fetchmail.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'fetchmail.c') diff --git a/fetchmail.c b/fetchmail.c index ade69cc2..93f4754a 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -116,6 +116,12 @@ static char *timestamp (void) #define timestamp rfc822timestamp #endif +static RETSIGTYPE donothing(int sig) +{ + extern volatile int lastsig; /* declared in idle.c */ + signal(sig, donothing); lastsig = sig; +} + int main(int argc, char **argv) { int bkgd = FALSE; @@ -718,6 +724,17 @@ int main(int argc, char **argv) report(stdout, GT_("sleeping at %s\n"), timestamp()); + /* + * With this simple hack, we make it possible for a foreground + * fetchmail to wake up one in daemon mode. What we want is the + * side effect of interrupting any sleep that may be going on, + * forcing fetchmail to re-poll its hosts. The second line is + * for people who think all system daemons wake up on SIGHUP. + */ + signal(SIGUSR1, donothing); + if (!getuid()) + signal(SIGHUP, donothing); + /* * OK, now pause until it's time for the next poll cycle. * A nonzero return indicates we received a wakeup signal; -- cgit v1.2.3