diff options
author | William A. Rowe Jr <wrowe@apache.org> | 2008-06-05 21:00:31 +0200 |
---|---|---|
committer | William A. Rowe Jr <wrowe@apache.org> | 2008-06-05 21:00:31 +0200 |
commit | 74d535b29dc54d9fa99b5c17cddafa7eb02b9d6f (patch) | |
tree | 82076fca95b25153902b3a68ecf26a47cf6f1f5b /server/mpm/winnt/mpm_winnt.c | |
parent | For winnt_mpm console mode, always reset our console handler to be the first, (diff) | |
download | apache2-74d535b29dc54d9fa99b5c17cddafa7eb02b9d6f.tar.xz apache2-74d535b29dc54d9fa99b5c17cddafa7eb02b9d6f.zip |
The environment may be manipulated by modules such as mod_perl, so regenerate
the passed env argument on each CreateProcess call.
PR: 44800 (part 2/3)
Submitted by: tdonovan
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@663699 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | server/mpm/winnt/mpm_winnt.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 4ba94c6b47..990e40897e 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -561,7 +561,6 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_ /* These NEVER change for the lifetime of this parent */ static char **args = NULL; - static char **env = NULL; static char pidbuf[28]; apr_status_t rv; @@ -572,6 +571,8 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_ HANDLE waitlist[2]; /* see waitlist_e */ char *cmd; char *cwd; + char **env; + int envc; apr_pool_create_ex(&ptemp, p, NULL, NULL); @@ -640,21 +641,15 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_ return -1; } - if (!env) - { - /* Build the env array, only once since it won't change - * for the lifetime of this parent process. - */ - int envc; - for (envc = 0; _environ[envc]; ++envc) { - ; - } - env = malloc((envc + 2) * sizeof (char*)); - memcpy(env, _environ, envc * sizeof (char*)); - apr_snprintf(pidbuf, sizeof(pidbuf), "AP_PARENT_PID=%i", parent_pid); - env[envc] = pidbuf; - env[envc + 1] = NULL; + /* Build the env array */ + for (envc = 0; _environ[envc]; ++envc) { + ; } + env = apr_palloc(ptemp, (envc + 2) * sizeof (char*)); + memcpy(env, _environ, envc * sizeof (char*)); + apr_snprintf(pidbuf, sizeof(pidbuf), "AP_PARENT_PID=%i", parent_pid); + env[envc] = pidbuf; + env[envc + 1] = NULL; rv = apr_proc_create(&new_child, cmd, args, env, attr, ptemp); if (rv != APR_SUCCESS) { |