|
From: <da...@ix...> - 2003-08-01 22:23:28
|
In article <3F0...@ta...>,
Leif Mortenson <wra...@li...> wrote:
>If anyone has any ideas, I'd appreciate the input.
This finally annoyed me enough to look into it (ok, actually it makes our
test system hang :-).
Following is inspired from bind.
Index: src/c/wrapper_unix.c
===================================================================
RCS file: /cvsroot/wrapper/wrapper/src/c/wrapper_unix.c,v
retrieving revision 1.41
diff -u -d -u -r1.41 wrapper_unix.c
--- src/c/wrapper_unix.c 9 Jul 2003 05:59:47 -0000 1.41
+++ src/c/wrapper_unix.c 1 Aug 2003 22:17:28 -0000
@@ -561,6 +561,7 @@
*/
void daemonize() {
pid_t pid;
+ int fd;
umask(0); /* clear file creation mask */
@@ -586,6 +587,19 @@
setsid(); /* become session leader */
signal(SIGHUP, SIG_IGN); /* don't let future opens allocate controlling terminals */
+ fd = open("/dev/null", O_RDWR, 0);
+ if (fd != -1) {
+ close(STDIN_FILENO);
+ dup2(fd, STDIN_FILENO);
+ close(STDOUT_FILENO);
+ dup2(fd, STDOUT_FILENO);
+ close(STDERR_FILENO);
+ dup2(fd, STDERR_FILENO);
+ if (fd != STDIN_FILENO &&
+ fd != STDOUT_FILENO &&
+ fd != STDERR_FILENO)
+ close(fd);
+ }
/* second fork */
if (wrapperData->isDebugging) {
Also, bind is apparently sufficiently paranoid to have:
if (setsid() == -1)
printf("setsid() FAILED: %s", strerror(errno));
Whether you want to make a similar change or not....
PS: We're in the middle of QA, if you could push out a release with
the above fix, I'd REALLY appreciate it. I'd rather use an official
release from you rather than an in house build.
mrc
--
Mike Castle da...@ix... www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
|