Fyi, as an aside, when building from CVS I am seeing
./config.status: 765: Syntax error: "done" unexpected (expecting ")")
The script:
#
# CONFIG_COMMANDS section.
#
for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
case $ac_dest in <- line 765
esac
done
{ (exit 0); exit 0; }
On Fri, Jan 04, 2002 at 04:42:24PM -0800, Aaron Bannert wrote:
> A couple things:
>
> This looks good in concept.
Thanks!
> This will have to apply to HEAD cleanly, so please modify/test/repost.
See below. I have changed the flag to NEW_SESSID for now. I have kept the
dont_fork variable name because because it describes exactly what it does.
Also, when debug is set, I now set dont_fork to 1. Comments?
> I'm not sure I like overloading the use of apr_proc_detach, and I'd prefer
> to see us come up with another function. I'm open to suggestions here.
> Maybe apr_proc_detach can only fork if it detects we are the process
> group leader?
I guess I could implement that, if that's the way we want to go.
> Another option would be to move the fork() out of apr_proc_detach()
> entirely.
Yes.
> DONT_FORK is misleading, since we're still going to fork() in other
> places, just not in the parent process and with the sole purpose of
> killing off the original parent. Any reason why this isn't just NEW_SESSID
> or something akin to that?
Sure, renamed accordingly.
> Given this patch I don't really see the purpose of NO_DETACH anymore, so
> maybe we could just steal that name?
Sounds good, but I'm not sure if it is a drop-in replacement. Are you thinking
of changing
if (!one_process && !no_detach) {
apr_proc_detach(new_sessid);
}
to
if (!one_process) {
apr_proc_detach(!no_detach);
}
?
Index: server/mpm/beos/beos.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/beos/beos.c,v
retrieving revision 1.75
diff -u -r1.75 beos.c
--- server/mpm/beos/beos.c 29 Dec 2001 23:16:23 -0000 1.75
+++ server/mpm/beos/beos.c 5 Jan 2002 05:07:12 -0000
@@ -993,16 +993,17 @@
static void beos_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
{
static int restart_num = 0;
- int no_detach, debug;
+ int no_detach, dont_fork, debug;
debug = ap_exists_config_define("DEBUG");
if (debug)
- no_detach = one_process = 1;
+ no_detach = dont_fork = one_process = 1;
else
{
one_process = ap_exists_config_define("ONE_PROCESS");
no_detach = ap_exists_config_define("NO_DETACH");
+ dont_fork = ap_exists_config_define("NEW_SESSID");
}
/* sigh, want this only the second time around */
@@ -1010,7 +1011,7 @@
is_graceful = 0;
if (!one_process && !no_detach)
- apr_proc_detach();
+ apr_proc_detach(dont_fork);
server_pid = getpid();
}
Index: server/mpm/perchild/perchild.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/perchild/perchild.c,v
retrieving revision 1.97
diff -u -r1.97 perchild.c
--- server/mpm/perchild/perchild.c 29 Dec 2001 23:16:23 -0000 1.97
+++ server/mpm/perchild/perchild.c 5 Jan 2002 05:07:14 -0000
@@ -1425,7 +1425,7 @@
static void perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
{
static int restart_num = 0;
- int no_detach, debug;
+ int no_detach, dont_fork, debug;
ap_directive_t *pdir;
int i;
int tmp_server_limit = DEFAULT_SERVER_LIMIT;
@@ -1433,12 +1433,12 @@
debug = ap_exists_config_define("DEBUG");
- if (debug) {
- no_detach = one_process = 1;
- }
+ if (debug)
+ no_detach = dont_fork = one_process = 1;
else {
one_process = ap_exists_config_define("ONE_PROCESS");
no_detach = ap_exists_config_define("NO_DETACH");
+ dont_fork = ap_exists_config_define("NEW_SESSID");
}
/* sigh, want this only the second time around */
@@ -1446,7 +1446,7 @@
is_graceful = 0;
if (!one_process && !no_detach) {
- apr_proc_detach();
+ apr_proc_detach(dont_fork);
}
my_pid = getpid();
Index: server/mpm/prefork/prefork.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.227
diff -u -r1.227 prefork.c
--- server/mpm/prefork/prefork.c 29 Dec 2001 23:16:24 -0000 1.227
+++ server/mpm/prefork/prefork.c 5 Jan 2002 05:07:15 -0000
@@ -1200,16 +1200,17 @@
static void prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
{
static int restart_num = 0;
- int no_detach, debug;
+ int no_detach, dont_fork, debug;
debug = ap_exists_config_define("DEBUG");
if (debug)
- no_detach = one_process = 1;
+ no_detach = dont_fork = one_process = 1;
else
{
no_detach = ap_exists_config_define("NO_DETACH");
one_process = ap_exists_config_define("ONE_PROCESS");
+ dont_fork = ap_exists_config_define("NEW_SESSID");
}
/* sigh, want this only the second time around */
@@ -1217,7 +1218,7 @@
is_graceful = 0;
if (!one_process && !no_detach) {
- apr_proc_detach();
+ apr_proc_detach(dont_fork);
}
parent_pid = ap_my_pid = getpid();
Index: server/mpm/worker/worker.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/worker/worker.c,v
retrieving revision 1.58
diff -u -r1.58 worker.c
--- server/mpm/worker/worker.c 29 Dec 2001 23:16:24 -0000 1.58
+++ server/mpm/worker/worker.c 5 Jan 2002 05:07:16 -0000
@@ -1542,7 +1542,7 @@
apr_pool_t *ptemp)
{
static int restart_num = 0;
- int no_detach, debug;
+ int no_detach, dont_fork, debug;
ap_directive_t *pdir;
ap_directive_t *max_clients = NULL;
@@ -1585,11 +1585,12 @@
debug = ap_exists_config_define("DEBUG");
if (debug)
- no_detach = one_process = 1;
+ no_detach = dont_fork = one_process = 1;
else
{
one_process = ap_exists_config_define("ONE_PROCESS");
no_detach = ap_exists_config_define("NO_DETACH");
+ dont_fork = ap_exists_config_define("NEW_SESSID");
}
/* sigh, want this only the second time around */
@@ -1597,7 +1598,7 @@
is_graceful = 0;
if (!one_process && !no_detach) {
- apr_proc_detach();
+ apr_proc_detach(dont_fork);
}
parent_pid = ap_my_pid = getpid();
}
Index: srclib/apr/include/apr_thread_proc.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_thread_proc.h,v
retrieving revision 1.78
diff -u -r1.78 apr_thread_proc.h
--- srclib/apr/include/apr_thread_proc.h 27 Dec 2001 17:02:59 -0000 1.78
+++ srclib/apr/include/apr_thread_proc.h 5 Jan 2002 05:07:17 -0000
@@ -552,7 +552,7 @@
/**
* Detach the process from the controlling terminal.
*/
-APR_DECLARE(apr_status_t) apr_proc_detach(void);
+APR_DECLARE(apr_status_t) apr_proc_detach(int dont_fork);
#if APR_HAS_OTHER_CHILD
Index: srclib/apr/threadproc/netware/proc.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/netware/proc.c,v
retrieving revision 1.3
diff -u -r1.3 proc.c
--- srclib/apr/threadproc/netware/proc.c 23 Oct 2001 17:30:08 -0000 1.3
+++ srclib/apr/threadproc/netware/proc.c 5 Jan 2002 05:07:18 -0000
@@ -345,13 +345,13 @@
}
newargs[i + 2] = NULL;
if (attr->detached) {
- apr_proc_detach();
+ apr_proc_detach(0);
}
execve(SHELL_PATH, (char * const *) newargs, (char * const *)env);
}
else {
if (attr->detached) {
- apr_proc_detach();
+ apr_proc_detach(0);
}
execve(progname, (char * const *)args, (char * const *)env);
}
Index: srclib/apr/threadproc/netware/procsup.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/netware/procsup.c,v
retrieving revision 1.1
diff -u -r1.1 procsup.c
--- srclib/apr/threadproc/netware/procsup.c 2 Aug 2001 20:29:14 -0000 1.1
+++ srclib/apr/threadproc/netware/procsup.c 5 Jan 2002 05:07:18 -0000
@@ -54,7 +54,7 @@
#include "threadproc.h"
-apr_status_t apr_proc_detach(void)
+apr_status_t apr_proc_detach(int dont_fork)
{
#if 0
int x;
@@ -64,14 +64,16 @@
#if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS)
/* 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, "unable to fork new process\n");
- exit(1); /* we can't do anything here, so just exit. */
+ if (!dont_fork) {
+ if ((x = fork()) > 0)
+ exit(0);
+ else if (x == -1) {
+ perror("fork");
+ fprintf(stderr, "unable to fork new process\n");
+ exit(1); /* we can't do anything here, so just exit. */
+ }
+ /* RAISE_SIGSTOP(DETACH);*/
}
-/* RAISE_SIGSTOP(DETACH);*/
#endif
#if APR_HAVE_SETSID
if ((pgrp = setsid()) == -1) {
Index: srclib/apr/threadproc/os2/proc.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/os2/proc.c,v
retrieving revision 1.47
diff -u -r1.47 proc.c
--- srclib/apr/threadproc/os2/proc.c 26 Oct 2001 02:31:04 -0000 1.47
+++ srclib/apr/threadproc/os2/proc.c 5 Jan 2002 05:07:19 -0000
@@ -620,7 +620,7 @@
-APR_DECLARE(apr_status_t) apr_proc_detach()
+APR_DECLARE(apr_status_t) apr_proc_detach(int dont_fork)
{
return APR_ENOTIMPL;
}
Index: srclib/apr/threadproc/unix/proc.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/unix/proc.c,v
retrieving revision 1.53
diff -u -r1.53 proc.c
--- srclib/apr/threadproc/unix/proc.c 11 Nov 2001 05:51:00 -0000 1.53
+++ srclib/apr/threadproc/unix/proc.c 5 Jan 2002 05:07:19 -0000
@@ -362,13 +362,13 @@
}
newargs[i + 2] = NULL;
if (attr->detached) {
- apr_proc_detach();
+ apr_proc_detach(0);
}
execve(SHELL_PATH, (char * const *) newargs, (char * const *)env);
}
else {
if (attr->detached) {
- apr_proc_detach();
+ apr_proc_detach(0);
}
execve(progname, (char * const *)args, (char * const *)env);
}
Index: srclib/apr/threadproc/unix/procsup.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/unix/procsup.c,v
retrieving revision 1.33
diff -u -r1.33 procsup.c
--- srclib/apr/threadproc/unix/procsup.c 28 Dec 2001 19:03:48 -0000 1.33
+++ srclib/apr/threadproc/unix/procsup.c 5 Jan 2002 05:07:19 -0000
@@ -54,7 +54,7 @@
#include "threadproc.h"
-APR_DECLARE(apr_status_t) apr_proc_detach(void)
+APR_DECLARE(apr_status_t) apr_proc_detach(int dont_fork)
{
int x;
pid_t pgrp;
@@ -63,14 +63,16 @@
#if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS)
/* 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, "unable to fork new process\n");
- exit(1); /* we can't do anything here, so just exit. */
+ if (!dont_fork) {
+ if ((x = fork()) > 0)
+ exit(0);
+ else if (x == -1) {
+ perror("fork");
+ fprintf(stderr, "unable to fork new process\n");
+ exit(1); /* we can't do anything here, so just exit. */
+ }
+ /* RAISE_SIGSTOP(DETACH);*/
}
-/* RAISE_SIGSTOP(DETACH);*/
#endif
#ifdef HAVE_SETSID
if ((pgrp = setsid()) == -1) {
--
Jos Backus _/ _/_/_/ Santa Clara, CA
_/ _/ _/
_/ _/_/_/
_/ _/ _/ _/
[EMAIL PROTECTED] _/_/ _/_/_/ use Std::Disclaimer;