|
From: Leif M. <le...@ta...> - 2003-08-02 16:31:52
|
Mike, you're awesome. That fixed it. Now that I see it, it makes sense.
But I don't
think I would have come up with that on my own. The changes are checked into
CVS. (Note that SF has the CVS archive mirrored so anon access is to 24 hour
old code.)
A lot has gone into this version. I'll try to get through the testing
and get a
release out sometime this week.
Cheers,
Leif
Mike Castle wrote:
>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
>
>
|