From 0a82e00316b14b8132b1638c6330e11dc9d10729 Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Tue, 20 Jun 2000 19:16:18 +0000 Subject: [PATCH] Remove unixd_detach function, because it is provided by APR as ap_detach. This also modifies the ap_detach function to look like unixd_detach. Finally all calls to unixd_detach are changed to ap_detach. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85635 13f79535-47bb-0310-9956-ffa450edef68 --- os/unix/unixd.c | 72 -------------------------- os/unix/unixd.h | 1 - server/mpm/dexter/dexter.c | 2 +- server/mpm/mpmt_pthread/mpmt_pthread.c | 2 +- server/mpm/prefork/prefork.c | 2 +- 5 files changed, 3 insertions(+), 76 deletions(-) diff --git a/os/unix/unixd.c b/os/unix/unixd.c index 8da6ee7ed0..561f15a0a4 100644 --- a/os/unix/unixd.c +++ b/os/unix/unixd.c @@ -77,78 +77,6 @@ unixd_config_rec unixd_config; -void unixd_detach(void) -{ - int x; - pid_t pgrp; - - chdir("/"); -#if !defined(MPE) && !defined(OS2) && !defined(TPF) -/* Don't detach for MPE because child processes can't survive the death of - the parent. */ - if ((x = fork()) > 0) - exit(0); - else if (x == -1) { - perror("fork"); - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, - "%s: unable to fork new process", ap_server_argv0); - exit(1); - } - RAISE_SIGSTOP(DETACH); -#endif -#ifdef HAVE_SETSID - if ((pgrp = setsid()) == -1) { - perror("setsid"); - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, - "%s: setsid failed", ap_server_argv0); - exit(1); - } -#elif defined(NEXT) || defined(NEWSOS) - if (setpgrp(0, getpid()) == -1 || (pgrp = getpgrp(0)) == -1) { - perror("setpgrp"); - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, - "%s: setpgrp or getpgrp failed", ap_server_argv0); - exit(1); - } -#elif defined(OS2) || defined(TPF) - /* OS/2 and TPF don't support process group IDs */ - pgrp = getpid(); -#elif defined(MPE) - /* MPE uses negative pid for process group */ - pgrp = -getpid(); -#else - if ((pgrp = setpgrp(getpid(), 0)) == -1) { - perror("setpgrp"); - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, - "%s: setpgrp failed", ap_server_argv0); - exit(1); - } -#endif - - /* close out the standard file descriptors */ - if (freopen("/dev/null", "r", stdin) == NULL) { - char buf[120]; - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, - "%s: unable to replace stdin with /dev/null: %s", - ap_server_argv0, ap_strerror(errno, buf, sizeof(buf))); - /* continue anyhow -- note we can't close out descriptor 0 because we - * have nothing to replace it with, and if we didn't have a descriptor - * 0 the next file would be created with that value ... leading to - * havoc. - */ - } - if (freopen("/dev/null", "w", stdout) == NULL) { - char buf[120]; - ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, - "%s: unable to replace stdout with /dev/null: %s", - ap_server_argv0, ap_strerror(errno, buf, sizeof(buf))); - } - /* stderr is a tricky one, we really want it to be the error_log, - * but we haven't opened that yet. So leave it alone for now and it'll - * be reopened moments later. - */ -} - /* Set group privileges. * * Note that we use the username as set in the config files, rather than diff --git a/os/unix/unixd.h b/os/unix/unixd.h index 0b9ee5522a..7fd99dcd17 100644 --- a/os/unix/unixd.h +++ b/os/unix/unixd.h @@ -83,7 +83,6 @@ typedef struct { } unixd_config_rec; extern unixd_config_rec unixd_config; -void unixd_detach(void); int unixd_setup_child(void); void unixd_pre_config(void); const char *unixd_set_user(cmd_parms *cmd, void *dummy, const char *arg); diff --git a/server/mpm/dexter/dexter.c b/server/mpm/dexter/dexter.c index 1cbbaae99c..0a5bfc3393 100644 --- a/server/mpm/dexter/dexter.c +++ b/server/mpm/dexter/dexter.c @@ -1231,7 +1231,7 @@ static void dexter_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) is_graceful = 0; if (!one_process) { - unixd_detach(); + ap_detach(); } my_pid = getpid(); diff --git a/server/mpm/mpmt_pthread/mpmt_pthread.c b/server/mpm/mpmt_pthread/mpmt_pthread.c index 0386e782ce..da17520c10 100644 --- a/server/mpm/mpmt_pthread/mpmt_pthread.c +++ b/server/mpm/mpmt_pthread/mpmt_pthread.c @@ -1261,7 +1261,7 @@ static void mpmt_pthread_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t is_graceful = 0; if (!one_process) { - unixd_detach(); + ap_detach(); } ap_my_pid = getpid(); } diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index c2ea771588..3e01e824f8 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -1601,7 +1601,7 @@ static void prefork_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) is_graceful = 0; if (!one_process) { - unixd_detach(); + ap_detach(); } ap_my_pid = getpid(); -- 2.40.0