aboutsummaryrefslogtreecommitdiffstats
path: root/daemon.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2001-02-10 21:20:35 +0000
committerEric S. Raymond <esr@thyrsus.com>2001-02-10 21:20:35 +0000
commitad89715a43c50c3d50409730318c42ba9dc96d3f (patch)
tree12a34e96650cef80cd8d6212c4238a9af2a53766 /daemon.c
parent53813c522b794b61c7080c40f95a1043912b2dcb (diff)
downloadfetchmail-ad89715a43c50c3d50409730318c42ba9dc96d3f.tar.gz
fetchmail-ad89715a43c50c3d50409730318c42ba9dc96d3f.tar.bz2
fetchmail-ad89715a43c50c3d50409730318c42ba9dc96d3f.zip
Dave Zarzycki's fixes.
svn path=/trunk/; revision=3039
Diffstat (limited to 'daemon.c')
-rw-r--r--daemon.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/daemon.c b/daemon.c
index 10c52b66..89f733ac 100644
--- a/daemon.c
+++ b/daemon.c
@@ -82,13 +82,36 @@ sigchld_handler (int sig)
lastsig = SIGCHLD;
}
+void deal_with_sigchld(void)
+{
+ RETSIGTYPE sigchld_handler(int);
+#ifdef HAVE_SIGACTION
+ struct sigaction sa_new;
+
+ memset (&sa_new, 0, sizeof sa_new);
+ sigemptyset (&sa_new.sa_mask);
+ sa_new.sa_handler = SIG_IGN;
+
+ /* set up to catch child process termination signals */
+ sa_new.sa_handler = sigchld_handler;
+ sigaction (SIGCHLD, &sa_new, NULL);
+#if defined(SIGPWR)
+ sigaction (SIGPWR, &sa_new, NULL);
+#endif
+#else
+ signal(SIGCHLD, sigchld_handler);
+#if defined(SIGPWR)
+ signal(SIGPWR, sigchld_handler);
+#endif
+#endif /* HAVE_SIGACTION */
+}
+
int
daemonize (const char *logfile, void (*termhook)(int))
/* detach from control TTY, become process group leader, catch SIGCHLD */
{
int fd;
pid_t childpid;
- RETSIGTYPE sigchld_handler(int);
#ifdef HAVE_SIGACTION
struct sigaction sa_new;
#endif /* HAVE_SIGACTION */
@@ -221,20 +244,7 @@ nottyDetach:
umask(022);
#endif
- /* set up to catch child process termination signals */
-#ifndef HAVE_SIGACTION
- signal(SIGCHLD, sigchld_handler);
-#else
- sa_new.sa_handler = sigchld_handler;
- sigaction (SIGCHLD, &sa_new, NULL);
-#endif /* HAVE_SIGACTION */
-#if defined(SIGPWR)
-#ifndef HAVE_SIGACTION
- signal(SIGPWR, sigchld_handler);
-#else
- sigaction (SIGPWR, &sa_new, NULL);
-#endif /* HAVE_SIGACTION */
-#endif
+ deal_with_sigchld();
return(0);
}