]> granicus.if.org Git - apache/commitdiff
Implement apr_proc_detach changes and allow -DNO_DETACH in the multi-process
authorAaron Bannert <aaron@apache.org>
Thu, 21 Feb 2002 18:52:28 +0000 (18:52 +0000)
committerAaron Bannert <aaron@apache.org>
Thu, 21 Feb 2002 18:52:28 +0000 (18:52 +0000)
mode to not "daemonize" while detaching from the controlling terminal.
This is necessary for Apache to work with process-management tools like
AIX's "System Resource Controller" as well as Dan Bernstein's "daemontools".

What this means is apache must _NOT_ be a process group leader if called
with the -DNO_DETACH flag.

Submitted from:     Jos Backus <josb@cncdsl.com>
Edited/Reviewed by: Aaron Bannert

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93535 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/beos/beos.c
server/mpm/experimental/perchild/perchild.c
server/mpm/perchild/perchild.c
server/mpm/prefork/prefork.c
server/mpm/worker/worker.c

index c58a5786f4c9b2b39edc4c15aff9515988685df2..c424f8cba47ee086682451daea5669c5c6cf1c8d 100644 (file)
@@ -1010,8 +1010,9 @@ static int beos_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptem
     if (restart_num++ == 1) {
         is_graceful = 0;
         
-        if (!one_process && !no_detach) {
-               rv = apr_proc_detach();
+        if (!one_process) {
+            rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND
+                                           : APR_PROC_DETACH_DAEMONIZE);
             if (rv != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
                              "apr_proc_detach failed");
index 1ea2675b4fba3ecf8e33b98e5c393ac0faaa9e75..a92cc0ddee9e2386ea4f495dc8a13b08298a319c 100644 (file)
@@ -1473,8 +1473,9 @@ static int perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem
     if (restart_num++ == 1) {
         is_graceful = 0;
 
-        if (!one_process && !no_detach) {
-            rv = apr_proc_detach();
+        if (!one_process) {
+            rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND
+                                           : APR_PROC_DETACH_DAEMONIZE);
             if (rv != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
                              "apr_proc_detach failed");
index 1ea2675b4fba3ecf8e33b98e5c393ac0faaa9e75..a92cc0ddee9e2386ea4f495dc8a13b08298a319c 100644 (file)
@@ -1473,8 +1473,9 @@ static int perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem
     if (restart_num++ == 1) {
         is_graceful = 0;
 
-        if (!one_process && !no_detach) {
-            rv = apr_proc_detach();
+        if (!one_process) {
+            rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND
+                                           : APR_PROC_DETACH_DAEMONIZE);
             if (rv != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
                              "apr_proc_detach failed");
index 352ffaf376bba45face75e2a0b59428c80c170bd..ccfdcae410ec38858a6a2a78b908594e18f17e01 100644 (file)
@@ -1216,8 +1216,9 @@ static int prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp
     if (restart_num++ == 1) {
        is_graceful = 0;
 
-    if (!one_process && !no_detach) {
-        rv = apr_proc_detach();
+    if (!one_process) {
+        rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND
+                                       : APR_PROC_DETACH_DAEMONIZE);
         if (rv != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
                          "apr_proc_detach failed");
index 309c0aac9b93e11cb006d99c67c9907df8baf83e..61a63ae43612a873828baae6ac72850c0ddb674f 100644 (file)
@@ -1551,17 +1551,17 @@ static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
             }
         }
         else if (!max_clients
-                && strncasecmp(pdir->directive, "MaxClients", 10) == 0) {
+                 && strncasecmp(pdir->directive, "MaxClients", 10) == 0) {
             max_clients = pdir;
         }
     }
 
     debug = ap_exists_config_define("DEBUG");
 
-    if (debug)
+    if (debug) {
         no_detach = one_process = 1;
-    else
-    {
+    }
+    else {
         one_process = ap_exists_config_define("ONE_PROCESS");
         no_detach = ap_exists_config_define("NO_DETACH");
     }
@@ -1570,8 +1570,9 @@ static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
     if (restart_num++ == 1) {
         is_graceful = 0;
 
-        if (!one_process && !no_detach) {
-            rv = apr_proc_detach();
+        if (!one_process) {
+            rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND
+                                           : APR_PROC_DETACH_DAEMONIZE);
             if (rv != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
                              "apr_proc_detach failed");