Excellent news, thank you all for your hard work on this!

Now that we have this feature in 2.0, can we also backport it into
the 1.3.* tree, for completeness sake? I've attached a patch for 1.3.23,
which is an updating of my patch for 1.3.22. The patch is also available
at:

        http://www.sub-rosa.com/handler/pub/apache-1.3.23-foreground-patch

--michael

Aaron Bannert <[EMAIL PROTECTED]> writes:

> On Thu, Dec 27, 2001 at 05:44:22PM -0800, Jos Backus wrote:
> > I'm willing to code a patch which allows Apache to run in the foreground in
> > its own session. Currently it kills the pgrp it is in even though it didn't
> > create it (bad practice imo - only destroy what you create). That is, if there
> > is any interest. A previous bugreport in this area was ignored so I may be
> > wasting my time. I'll interpret no response as ``no interest, go away''.
> 
> Thanks for the original patch! I just committed the last chunk from
> the patch I posted last week, so we should be good to go.
> 
> -aaron

-- 
[EMAIL PROTECTED] (michael handler)                           washington, dc
--- http_main.c.dist    Thu Feb 21 16:57:02 2002
+++ http_main.c Thu Feb 21 17:02:28 2002
@@ -341,6 +341,8 @@
 
 static int one_process = 0;
 
+static int do_detach = 1;
+
 /* set if timeouts are to be handled by the children and not by the parent.
  * i.e. child_timeouts = !standalone || one_process.
  */
@@ -1346,7 +1348,7 @@
 #ifdef WIN32
     fprintf(stderr, "Usage: %s [-D name] [-d directory] [-f file] [-n service]\n", 
bin);
     fprintf(stderr, "       %s [-C \"directive\"] [-c \"directive\"] [-k signal]\n", 
pad);
-    fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]\n", pad);
+    fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T] [-F]\n", pad);
 #else /* !WIN32 */
 #ifdef SHARED_CORE
     fprintf(stderr, "Usage: %s [-R directory] [-D name] [-d directory] [-f file]\n", 
bin);
@@ -1354,7 +1356,7 @@
     fprintf(stderr, "Usage: %s [-D name] [-d directory] [-f file]\n", bin);
 #endif
     fprintf(stderr, "       %s [-C \"directive\"] [-c \"directive\"]\n", pad);
-    fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]\n", pad);
+    fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T] [-F]\n", pad);
     fprintf(stderr, "Options:\n");
 #ifdef SHARED_CORE
     fprintf(stderr, "  -R directory     : specify an alternate location for shared 
object files\n");
@@ -1376,6 +1378,7 @@
 #endif
     fprintf(stderr, "  -t               : run syntax check for config files (with 
docroot check)\n");
     fprintf(stderr, "  -T               : run syntax check for config files (without 
docroot check)\n");
+    fprintf(stderr, "  -F               : run main process in foreground, for process 
+supervisors\n");
 #ifdef WIN32
     fprintf(stderr, "  -n name          : name the Apache service for -k options 
below;\n");
     fprintf(stderr, "  -k stop|shutdown : tell running Apache to shutdown\n");
@@ -3365,14 +3368,16 @@
     !defined(BONE)
 /* 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");
-       fprintf(stderr, "%s: unable to fork new process\n", ap_server_argv0);
-       exit(1);
+    if (do_detach) {
+        if ((x = fork()) > 0)
+            exit(0);
+        else if (x == -1) {
+            perror("fork");
+           fprintf(stderr, "%s: unable to fork new process\n", ap_server_argv0);
+           exit(1);
+        }
+        RAISE_SIGSTOP(DETACH);
     }
-    RAISE_SIGSTOP(DETACH);
 #endif
 #ifndef NO_SETSID
     if ((pgrp = setsid()) == -1) {
@@ -5292,7 +5297,7 @@
     ap_setup_prelinked_modules();
 
     while ((c = getopt(argc, argv,
-                                   "D:C:c:xXd:f:vVlLR:StTh"
+                                   "D:C:c:xXd:Ff:vVlLR:StTh"
 #ifdef DEBUG_SIGSTOP
                                    "Z:"
 #endif
@@ -5314,6 +5319,9 @@
        case 'd':
            ap_cpystrn(ap_server_root, optarg, sizeof(ap_server_root));
            break;
+       case 'F':
+           do_detach = 0;
+           break;
        case 'f':
            ap_cpystrn(ap_server_confname, optarg, sizeof(ap_server_confname));
            break;
@@ -7190,9 +7198,9 @@
         reparsed = 1;
     }
 
-    while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLz:Z:wiuStThk:n:W:")) != -1) {
+    while ((c = getopt(argc, argv, "D:C:c:Xd:Ff:vVlLz:Z:wiuStThk:n:W:")) != -1) {
 #else /* !WIN32 */
-    while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLsStTh")) != -1) {
+    while ((c = getopt(argc, argv, "D:C:c:Xd:Ff:vVlLsStTh")) != -1) {
 #endif
         char **new;
        switch (c) {
@@ -7301,6 +7309,9 @@
                     && ap_server_root[strlen(ap_server_root) - 1] == '/')
                 ap_server_root[strlen(ap_server_root) - 1] = '\0';
            break;
+       case 'F':
+           do_detach = 0;
+           break;
        case 'f':
             ap_cpystrn(ap_server_confname,
                        ap_os_canonical_filename(pcommands, optarg),
@@ -7690,13 +7701,14 @@
      * but only handle the -L option 
      */
     llp_dir = SHARED_CORE_DIR;
-    while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLR:SZ:tTh")) != -1) {
+    while ((c = getopt(argc, argv, "D:C:c:Xd:Ff:vVlLR:SZ:tTh")) != -1) {
        switch (c) {
        case 'D':
        case 'C':
        case 'c':
        case 'X':
        case 'd':
+       case 'F':
        case 'f':
        case 'v':
        case 'V':

Reply via email to