Return-Path: Delivered-To: apmail-apr-cvs-archive@www.apache.org Received: (qmail 74627 invoked from network); 23 Jun 2004 12:26:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 23 Jun 2004 12:26:30 -0000 Received: (qmail 13925 invoked by uid 500); 23 Jun 2004 12:20:54 -0000 Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 13743 invoked by uid 500); 23 Jun 2004 12:20:51 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 13434 invoked by uid 99); 23 Jun 2004 12:20:48 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Date: 23 Jun 2004 12:20:44 -0000 Message-ID: <20040623122044.71235.qmail@minotaur.apache.org> From: trawick@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/threadproc/win32 proc.c X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N trawick 2004/06/23 05:20:44 Modified: . CHANGES include apr_thread_proc.h threadproc/os2 proc.c threadproc/unix proc.c threadproc/win32 proc.c Log: Add command type APR_SHELLCMD_ENV for creating a process which is started by the shell and which inherits the parent's environment variables. The immediate use for this is with Apache httpd's piped loggers, correcting a regression since 1.3. In general, applications starting child processes often want the child to run with the same environment variables, so this plugs a hole in the API. Revision Changes Path 1.474 +4 -0 apr/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apr/CHANGES,v retrieving revision 1.473 retrieving revision 1.474 diff -u -r1.473 -r1.474 --- CHANGES 14 Jun 2004 22:24:56 -0000 1.473 +++ CHANGES 23 Jun 2004 12:20:44 -0000 1.474 @@ -7,6 +7,10 @@ Changes with APR 1.0 + *) Add command type APR_SHELLCMD_ENV for creating a process + which is started by the shell and which inherits the parent's + environment variables. [Jeff Trawick] + *) Fix apr_threadattr_detach_set() on Mac OS X. PR 28472. [INOUE Seiichiro ] 1.111 +6 -3 apr/include/apr_thread_proc.h Index: apr_thread_proc.h =================================================================== RCS file: /home/cvs/apr/include/apr_thread_proc.h,v retrieving revision 1.110 retrieving revision 1.111 diff -u -r1.110 -r1.111 --- apr_thread_proc.h 15 Jun 2004 20:51:25 -0000 1.110 +++ apr_thread_proc.h 23 Jun 2004 12:20:44 -0000 1.111 @@ -45,7 +45,10 @@ APR_SHELLCMD, /**< use the shell to invoke the program */ APR_PROGRAM, /**< invoke the program directly, no copied env */ APR_PROGRAM_ENV, /**< invoke the program, replicating our environment */ - APR_PROGRAM_PATH /**< find program on PATH, use our environment */ + APR_PROGRAM_PATH, /**< find program on PATH, use our environment */ + APR_SHELLCMD_ENV, /**< use the shell to invoke the program, + * replicating our environment + */ } apr_cmdtype_e; typedef enum { @@ -546,8 +549,8 @@ * one should be the program name. * @param env The new environment table for the new process. This * should be a list of NULL-terminated strings. This argument - * is ignored for APR_PROGRAM_ENV and APR_PROGRAM_PATH types - * of commands. + * is ignored for APR_PROGRAM_ENV, APR_PROGRAM_PATH, and + * APR_SHELLCMD_ENV types of commands. * @param attr the procattr we should use to determine how to create the new * process * @param pool The pool to use. 1.62 +3 -1 apr/threadproc/os2/proc.c Index: proc.c =================================================================== RCS file: /home/cvs/apr/threadproc/os2/proc.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- proc.c 14 Jun 2004 17:26:19 -0000 1.61 +++ proc.c 23 Jun 2004 12:20:44 -0000 1.62 @@ -333,7 +333,9 @@ /* ### how to handle APR_PROGRAM_ENV and APR_PROGRAM_PATH? */ - if (attr->cmdtype == APR_SHELLCMD || strcasecmp(extension, ".cmd") == 0) { + if (attr->cmdtype == APR_SHELLCMD || + attr->cmdtype == APR_SHELLCMD_ENV || + strcasecmp(extension, ".cmd") == 0) { strcpy(interpreter, "#!" SHELL_PATH); extra_arg = "/C"; } else if (stricmp(extension, ".exe") != 0) { 1.74 +8 -2 apr/threadproc/unix/proc.c Index: proc.c =================================================================== RCS file: /home/cvs/apr/threadproc/unix/proc.c,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- proc.c 14 Jun 2004 17:26:19 -0000 1.73 +++ proc.c 23 Jun 2004 12:20:44 -0000 1.74 @@ -392,7 +392,8 @@ exit(-1); /* We have big problems, the child should exit. */ } - if (attr->cmdtype == APR_SHELLCMD) { + if (attr->cmdtype == APR_SHELLCMD || + attr->cmdtype == APR_SHELLCMD_ENV) { int onearg_len = 0; const char *newargs[4]; @@ -443,7 +444,12 @@ apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); } - execve(SHELL_PATH, (char * const *) newargs, (char * const *)env); + if (attr->cmdtype == APR_SHELLCMD) { + execve(SHELL_PATH, (char * const *) newargs, (char * const *)env); + } + else { + execv(SHELL_PATH, (char * const *)newargs); + } } else if (attr->cmdtype == APR_PROGRAM) { if (attr->detached) { 1.93 +4 -2 apr/threadproc/win32/proc.c Index: proc.c =================================================================== RCS file: /home/cvs/apr/threadproc/win32/proc.c,v retrieving revision 1.92 retrieving revision 1.93 diff -u -r1.92 -r1.93 --- proc.c 14 Jun 2004 17:26:20 -0000 1.92 +++ proc.c 23 Jun 2004 12:20:44 -0000 1.93 @@ -349,7 +349,7 @@ } #ifndef _WIN32_WCE - if (attr->cmdtype == APR_SHELLCMD) { + if (attr->cmdtype == APR_SHELLCMD || attr->cmdtype == APR_SHELLCMD_ENV) { char *shellcmd = getenv("COMSPEC"); if (!shellcmd) { return APR_EINVAL; @@ -445,8 +445,10 @@ } } - if (!env || attr->cmdtype == APR_PROGRAM_ENV) + if (!env || attr->cmdtype == APR_PROGRAM_ENV || + attr->cmdtype == APR_SHELLCMD_ENV) { pEnvBlock = NULL; + } else { apr_size_t iEnvBlockLen; /*