aboutsummaryrefslogtreecommitdiffstats
path: root/daemon.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-06-26 19:09:01 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-06-26 19:09:01 +0000
commitd98d211d8b8832c01d8ccccb501fd419b8f430e1 (patch)
treefadee8d3409208b78d9bd737d0f7920c889ed2f5 /daemon.c
parent62a66ecb705b41866729a6d7eb70cf64f8e17cd8 (diff)
downloadfetchmail-d98d211d8b8832c01d8ccccb501fd419b8f430e1.tar.gz
fetchmail-d98d211d8b8832c01d8ccccb501fd419b8f430e1.tar.bz2
fetchmail-d98d211d8b8832c01d8ccccb501fd419b8f430e1.zip
This is what I sent Harris.
svn path=/trunk/; revision=9
Diffstat (limited to 'daemon.c')
-rw-r--r--daemon.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/daemon.c b/daemon.c
index 56aab4ef..cdfb35f9 100644
--- a/daemon.c
+++ b/daemon.c
@@ -25,6 +25,9 @@
BSD systems.
$Log: daemon.c,v $
+ Revision 1.2 1996/06/26 19:08:57 esr
+ This is what I sent Harris.
+
Revision 1.1 1996/06/25 14:32:01 esr
Initial revision
@@ -98,7 +101,7 @@ sigchld_handler ()
become process group leader of our own process group,
and set up to catch child process termination signals.
arguments:
- options command-line options.
+ logfile file to direct stdout and stderr to, if non-NULL.
ret. value: none.
globals: refers to the address of sigchld_handler().
@@ -106,12 +109,12 @@ sigchld_handler ()
*****************************************************************/
int
-daemonize (options)
-struct optrec *options;
+daemonize (logfile)
+const char *logfile;
{
int fd;
pid_t childpid;
- RETSIGTYPE sigchild_handler();
+ RETSIGTYPE sigchld_handler();
/* if we are started by init (process 1) via /etc/inittab we needn't
bother to detach from our process group context */
@@ -195,13 +198,15 @@ nottyDetach:
return(PS_IOERR);
}
-
- if (dup(fd) < 0) { /* stdout */
- log_perror("dup");
- return(PS_IOERR);
- }
+ if (logfile)
+ open(logfile, O_CREAT|O_WRONLY, 0777); /* stdout */
+ else
+ if (dup(fd) < 0) { /* stdout */
+ perror("dup");
+ return(PS_IOERR);
+ }
if (dup(fd) < 0) { /* stderr */
- log_perror("dup");
+ perror("dup");
return(PS_IOERR);
}
@@ -216,6 +221,6 @@ nottyDetach:
#endif
/* set up to catch child process termination signals */
- signal(SIGCLD, sigchild_handler);
+ signal(SIGCLD, sigchld_handler);
}