Skip to content

Commit

Permalink
A couple forking fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 1, 2008
1 parent 40f153a commit e4796d7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions nph-offload.c
Expand Up @@ -587,6 +587,12 @@ static void terminate(void)

if (GDebugFilePointer != NULL)
fclose(GDebugFilePointer);

if (stdin) fclose(stdin);
if (stdout) fclose(stdout);
if (stderr) fclose(stderr);
stdin = stdout = stderr = NULL;

exit(0);
} // terminate

Expand Down Expand Up @@ -1612,7 +1618,6 @@ static const char *readClientHeaders(const int fd, const struct sockaddr *addr)

static inline int daemonChild(const int fd, const struct sockaddr *addr)
{
setsid();
if (fd == 0)
dup2(fd, 1);
else if (fd == 1)
Expand All @@ -1634,18 +1639,15 @@ static inline int daemonChild(const int fd, const struct sockaddr *addr)
serverMainline(0, NULL, environ);
} // if

if (stdin) fclose(stdin);
if (stdout) fclose(stdout);
if (stderr) fclose(stderr);
stdin = stdout = stderr = NULL;

// !!! FIXME: write an access_log or error_log.
exit(0);
terminate();
} // daemonChild


static inline int daemonMainline(int argc, char **argv, char **envp)
{
signal(SIGCHLD, SIG_IGN);

// !!! FIXME: move to own function.
#if GLISTENDAEMONIZE
{
Expand All @@ -1669,8 +1671,6 @@ static inline int daemonMainline(int argc, char **argv, char **envp)
}
#endif

signal(SIGCHLD, SIG_IGN);

// !!! FIXME: move to own function.
struct addrinfo hints;
memset(&hints, '\0', sizeof (hints));
Expand Down

0 comments on commit e4796d7

Please sign in to comment.