summaryrefslogtreecommitdiff
path: root/threadproc
diff options
context:
space:
mode:
authortrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2004-06-23 12:20:44 +0000
committertrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2004-06-23 12:20:44 +0000
commit30657c4f011350df7489c3d7e5ba018ecf3c9cc9 (patch)
tree343a492c412dbe3195a865b3a4be4a3ef95fa689 /threadproc
parentdff74a633a0eb6e9452c3fe9615f273f61082c6f (diff)
downloadlibapr-30657c4f011350df7489c3d7e5ba018ecf3c9cc9.tar.gz
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. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@65213 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc')
-rw-r--r--threadproc/os2/proc.c4
-rw-r--r--threadproc/unix/proc.c10
-rw-r--r--threadproc/win32/proc.c6
3 files changed, 15 insertions, 5 deletions
diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c
index c0ff58407..4edb45221 100644
--- a/threadproc/os2/proc.c
+++ b/threadproc/os2/proc.c
@@ -333,7 +333,9 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname
/* ### 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) {
diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c
index 5c5536b22..7f01425bc 100644
--- a/threadproc/unix/proc.c
+++ b/threadproc/unix/proc.c
@@ -392,7 +392,8 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
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_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
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) {
diff --git a/threadproc/win32/proc.c b/threadproc/win32/proc.c
index 3073b1a27..e7c21c105 100644
--- a/threadproc/win32/proc.c
+++ b/threadproc/win32/proc.c
@@ -349,7 +349,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
}
#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 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
}
}
- 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;
/*