From b58d2a6bc3e4ca15d0afae4e31a22f9593810e89 Mon Sep 17 00:00:00 2001 From: gstein Date: Mon, 28 Jan 2002 21:58:16 +0000 Subject: Add a couple new command types to process creation: APR_PROGRAM_ENV: start the program using the caller's environment APR_PROGRAM_PATH: search PATH for the program, use caller's env (the normal APR_PROGRAM isolates the env and does not use PATH) The BeOS, OS/2, and Win32 implementations are incomplete. These two new forms just default back to APR_PROGRAM for now. (although BeOS doesn't even distinguish between APR_SHELLCMD and APR_PROGRAM!) On Unix and Netware, these map into execv() and execvp() calls. Also clarified some doc for the enums in apr_thread_proc.h a bit. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62840 13f79535-47bb-0310-9956-ffa450edef68 --- threadproc/beos/proc.c | 2 ++ threadproc/netware/proc.c | 15 ++++++++++++++- threadproc/os2/proc.c | 2 ++ threadproc/unix/proc.c | 15 ++++++++++++++- threadproc/win32/proc.c | 2 ++ 5 files changed, 34 insertions(+), 2 deletions(-) (limited to 'threadproc') diff --git a/threadproc/beos/proc.c b/threadproc/beos/proc.c index 7bfa25d64..edd36de60 100644 --- a/threadproc/beos/proc.c +++ b/threadproc/beos/proc.c @@ -249,6 +249,8 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, } newargs[nargs] = NULL; + /* ### we should be looking at attr->cmdtype in here... */ + newproc = load_image(nargs, (const char**)newargs, (const char**)env); /* load_image copies the data so now we can free it... */ diff --git a/threadproc/netware/proc.c b/threadproc/netware/proc.c index 7052669b6..69c1aab51 100644 --- a/threadproc/netware/proc.c +++ b/threadproc/netware/proc.c @@ -349,12 +349,25 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } execve(SHELL_PATH, (char * const *) newargs, (char * const *)env); } - else { + else if (attr->cmdtype == APR_PROGRAM) { if (attr->detached) { apr_proc_detach(); } execve(progname, (char * const *)args, (char * const *)env); } + else if (attr->cmdtype == APR_PROGRAM_ENV) { + if (attr->detached) { + apr_proc_detach(); + } + execv(progname, (char * const *)args); + } + else { + /* APR_PROGRAM_PATH */ + if (attr->detached) { + apr_proc_detach(); + } + execvp(progname, (char * const *)args); + } exit(-1); /* if we get here, there is a problem, so exit with an */ /* error code. */ } diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c index 927fd96ec..08af08794 100644 --- a/threadproc/os2/proc.c +++ b/threadproc/os2/proc.c @@ -345,6 +345,8 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname if (extension == NULL || strchr(extension, '/') || strchr(extension, '\\')) extension = ""; + /* ### how to handle APR_PROGRAM_ENV and APR_PROGRAM_PATH? */ + if (attr->cmdtype == APR_SHELLCMD || strcasecmp(extension, ".cmd") == 0) { strcpy(interpreter, "#!" SHELL_PATH); extra_arg = "/C"; diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index 4872f7508..ff80f2cfe 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -366,12 +366,25 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, } execve(SHELL_PATH, (char * const *) newargs, (char * const *)env); } - else { + else if (attr->cmdtype == APR_PROGRAM) { if (attr->detached) { apr_proc_detach(); } execve(progname, (char * const *)args, (char * const *)env); } + else if (attr->cmdtype == APR_PROGRAM_ENV) { + if (attr->detached) { + apr_proc_detach(); + } + execv(progname, (char * const *)args); + } + else { + /* APR_PROGRAM_PATH */ + if (attr->detached) { + apr_proc_detach(); + } + execvp(progname, (char * const *)args); + } exit(-1); /* if we get here, there is a problem, so exit with an */ /* error code. */ } diff --git a/threadproc/win32/proc.c b/threadproc/win32/proc.c index 10ea0f850..400d7ab23 100644 --- a/threadproc/win32/proc.c +++ b/threadproc/win32/proc.c @@ -343,6 +343,8 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, i++; } + /* ### how to handle APR_PROGRAM_ENV and APR_PROGRAM_PATH? */ + if (attr->cmdtype == APR_SHELLCMD) { char *shellcmd = getenv("COMSPEC"); if (!shellcmd) -- cgit v1.2.1