From c4aa3433b8d186e07678a2c40b2a12751fe975cf Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 27 Jun 1996 19:22:33 +0000 Subject: Sent to ceharris. svn path=/trunk/; revision=10 --- daemon.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'daemon.c') diff --git a/daemon.c b/daemon.c index cdfb35f9..0776d062 100644 --- a/daemon.c +++ b/daemon.c @@ -25,6 +25,9 @@ BSD systems. $Log: daemon.c,v $ + Revision 1.3 1996/06/27 19:22:31 esr + Sent to ceharris. + Revision 1.2 1996/06/26 19:08:57 esr This is what I sent Harris. @@ -57,6 +60,7 @@ #include "popclient.h" +static void (*my_termhook)(void); /****************************************************************** function: sigchld_handler @@ -80,6 +84,9 @@ sigchld_handler () int status; #endif + if (my_termhook) + (*my_termhook)(); + #if defined(HAVE_WAIT3) while ((pid = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0) ; /* swallow 'em up. */ @@ -109,8 +116,9 @@ sigchld_handler () *****************************************************************/ int -daemonize (logfile) +daemonize (logfile, termhook) const char *logfile; +void (*termhook)(void); { int fd; pid_t childpid; @@ -119,6 +127,8 @@ const char *logfile; /* if we are started by init (process 1) via /etc/inittab we needn't bother to detach from our process group context */ + my_termhook = termhook; + if (getppid() == 1) goto nottyDetach; -- cgit v1.2.3