]> granicus.if.org Git - apache/commitdiff
Remove unixd_detach function, because it is provided by APR as ap_detach.
authorRyan Bloom <rbb@apache.org>
Tue, 20 Jun 2000 19:16:18 +0000 (19:16 +0000)
committerRyan Bloom <rbb@apache.org>
Tue, 20 Jun 2000 19:16:18 +0000 (19:16 +0000)
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
os/unix/unixd.h
server/mpm/dexter/dexter.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/prefork/prefork.c

index 8da6ee7ed085810dcf9bf114d22c30691b797d30..561f15a0a48dc621a39f38863e23c50f66255a6b 100644 (file)
 
 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
index 0b9ee5522ad78aefd25642e66bf9e88282feb624..7fd99dcd175094649faf0169f4d41e89e1eee808 100644 (file)
@@ -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);
index 1cbbaae99c1b338783b53b36d3f1669eb5d841ce..0a5bfc3393c691529c0ecdf5207a988ee1f98414 100644 (file)
@@ -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();
index 0386e782ce46394eb3395341348d100edc032e64..da17520c10a8cd12fc4e1481c63149187a4dba42 100644 (file)
@@ -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();
     }
index c2ea7715882c2643522167b37e0c2b07ebc4425c..3e01e824f8959b913a0b57d6253a45f1c4237cce 100644 (file)
@@ -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();