Return-Path: Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 31957 invoked by uid 500); 13 May 2002 21:53:39 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 31876 invoked from network); 13 May 2002 21:53:39 -0000 X-Curiosity: Killed the Cat X-Huis-aan-Huis-deur-sticker: nee-nee X-Spam: no X-Passed: MX on Gandalf.WebWeaving.org Mon, 13 May 2002 14:53:34 -0700 (PDT) and masked X-No-Spam: Neither the receipients nor the senders email address(s) are to be used for Unsolicited (Commercial) Email without the explicit written consent of either party; as a per-message fee is incurred for inbound and outbound traffic to the originator. Date: Mon, 13 May 2002 14:53:34 -0700 (PDT) From: dirkx@covalent.net X-X-Sender: dirkx@mobile.webweaving.org To: jerenkrantz@apache.org cc: dev@httpd.apache.org Subject: Re: Deamon tools In-Reply-To: <20020513144713.N11751@apache.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Mon, 13 May 2002, Justin Erenkrantz wrote: > Unified diff, please. =) My brain can't parse that style of > diffs. -- justin Hmm - sorry - blame MacOS-X - somehow unified diffs break. Here is one from a BSD box: Dw Index: src/CHANGES =================================================================== RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1817 diff -u -r1.1817 CHANGES --- src/CHANGES 6 May 2002 08:34:13 -0000 1.1817 +++ src/CHANGES 13 May 2002 21:53:03 -0000 @@ -1,5 +1,11 @@ Changes with Apache 1.3.25 + *) Added a '-F' flag; which causes the mother/supervisor process to + no longer fork down and detach. But instead stays attached to + the tty - thus making live for automatic restart and exit checking + code easier. [ Contributed by Michael Handler , + Jos Backus [ Dirk-Willem van Gulik ]]. + *) Make apxs.pl more flexible (file extensions like .so or .dll are no longer hardcoded). [Stipe Tolj ] Index: src/main/http_main.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v retrieving revision 1.580 diff -u -r1.580 http_main.c --- src/main/http_main.c 22 Apr 2002 18:23:19 -0000 1.580 +++ src/main/http_main.c 13 May 2002 21:53:05 -0000 @@ -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. */ @@ -1349,7 +1351,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); @@ -1357,7 +1359,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"); @@ -1380,6 +1382,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"); @@ -3374,17 +3377,19 @@ !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) { + if ((do_detach) && ((pgrp = setsid()) == -1)) { perror("setsid"); fprintf(stderr, "%s: setsid failed\n", ap_server_argv0); exit(1); @@ -5312,7 +5317,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 @@ -5334,6 +5339,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; @@ -7215,9 +7223,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:vVlLesStTh")) != -1) { + while ((c = getopt(argc, argv, "D:C:c:Xd:fF:vVlLesStTh")) != -1) { #endif char **new; switch (c) { @@ -7339,6 +7347,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), @@ -7733,13 +7744,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':