aboutsummaryrefslogtreecommitdiffstats
path: root/fetchmail.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-09-28 20:28:13 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-09-28 20:28:13 +0000
commit38d13c350ef8e082435fccacfb0f7749be3a15a1 (patch)
treeb3e959afe29f59a91b4075f5708a3056e1f7cb40 /fetchmail.c
parented3bd0c5048cac6def24c3d70f3eaaf449a38a82 (diff)
downloadfetchmail-38d13c350ef8e082435fccacfb0f7749be3a15a1.tar.gz
fetchmail-38d13c350ef8e082435fccacfb0f7749be3a15a1.tar.bz2
fetchmail-38d13c350ef8e082435fccacfb0f7749be3a15a1.zip
Closer control of interrupts.
svn path=/trunk/; revision=1431
Diffstat (limited to 'fetchmail.c')
-rw-r--r--fetchmail.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/fetchmail.c b/fetchmail.c
index c255530e..80856024 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -304,6 +304,14 @@ int main (int argc, char **argv)
if (!nodetach)
daemonize(logfile, termhook);
error( 0, 0, "starting fetchmail %s daemon ", RELEASE_ID);
+
+ /*
+ * We'll set up a handler for these when we're sleeping,
+ * but ignore them otherwise so as not to interrupt a poll.
+ */
+ signal(SIGUSR1, SIG_IGN);
+ if (poll_interval && !getuid())
+ signal(SIGHUP, SIG_IGN);
}
/* beyond here we don't want more than one fetchmail running per user */
@@ -315,20 +323,8 @@ int main (int argc, char **argv)
signal(SIGPIPE, termhook);
signal(SIGQUIT, termhook);
- /*
- * 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.
- */
- signal(SIGUSR1, donothing);
-
- /* pacify people who think all system daemons wake up on SIGHUP */
- if (poll_interval && !getuid())
- signal(SIGHUP, donothing);
-
/* here's the exclusion lock */
- if ( (lockfp = fopen(lockfile,"w")) != NULL ) {
+ if ((lockfp = fopen(lockfile,"w")) != NULL) {
fprintf(lockfp,"%d",getpid());
if (poll_interval)
fprintf(lockfp," %d", poll_interval);
@@ -467,6 +463,17 @@ int main (int argc, char **argv)
}
/*
+ * 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);
+
+ /*
* We can't use sleep(3) here because we need an alarm(3)
* equivalent in order to implement server nonresponse timeout.
* We'll just assume setitimer(2) is available since fetchmail
@@ -494,6 +501,11 @@ int main (int argc, char **argv)
}
}
+ /* now lock out interrupts again */
+ signal(SIGUSR1, SIG_IGN);
+ if (!getuid())
+ signal(SIGHUP, SIG_IGN);
+
if (outlevel == O_VERBOSE)
{
time_t now;