summaryrefslogtreecommitdiff
path: root/threadproc/os2
diff options
context:
space:
mode:
authorBrian Havard <bjh@apache.org>1999-11-03 08:06:00 +0000
committerBrian Havard <bjh@apache.org>1999-11-03 08:06:00 +0000
commit550325eda3aac5a64ea9d3bdd175028d5b3d3edb (patch)
treed4b30e08b0a15a71e3816e2fe4beac14d4a5a645 /threadproc/os2
parent4e970b5b2a63a7378476eb7570aa624bf9d572c9 (diff)
downloadapr-550325eda3aac5a64ea9d3bdd175028d5b3d3edb.tar.gz
Some fixes for OS/2 process creation:
- Allow NULL environment block - Allow .exe extension to be omitted git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@59442 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc/os2')
-rw-r--r--threadproc/os2/proc.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c
index e5f5ab6a8..17e26bd04 100644
--- a/threadproc/os2/proc.c
+++ b/threadproc/os2/proc.c
@@ -261,15 +261,19 @@ ap_status_t ap_create_process(struct proc_t **new, const char *progname,
interpreter[0] = 0;
extension = strrchr(progname, '.');
- if (extension == NULL)
+ if (extension == NULL || strchr(extension, '/') || strchr(extension, '\\'))
extension = "";
if (attr->cmdtype == APR_SHELLCMD || strcasecmp(extension, ".cmd") == 0) {
strcpy(interpreter, "#!" SHELL_PATH);
extra_arg = "/C";
- } else if (stricmp(progname, ".exe") != 0) {
+ } else if (stricmp(extension, ".exe") != 0) {
status = ap_open(&progfile, progname, APR_READ|APR_BUFFERED, 0, cont);
+ if (status == APR_ENOENT) {
+ progname = ap_pstrcat(cont, progname, ".exe", NULL);
+ }
+
if (status == APR_SUCCESS) {
status = ap_fgets(interpreter, sizeof(interpreter), progfile);
@@ -350,18 +354,21 @@ ap_status_t ap_create_process(struct proc_t **new, const char *progname,
}
/* Create environment block from list of envariables */
- for (env_len=1, e=0; env[e]; e++)
- env_len += strlen(env[e]) + 1;
+ if (env) {
+ for (env_len=1, e=0; env[e]; e++)
+ env_len += strlen(env[e]) + 1;
- env_block = ap_palloc(cont, env_len);
- env_block_pos = env_block;
+ env_block = ap_palloc(cont, env_len);
+ env_block_pos = env_block;
- for (e=0; env[e]; e++) {
- strcpy(env_block_pos, env[e]);
- env_block_pos += strlen(env_block_pos) + 1;
- }
+ for (e=0; env[e]; e++) {
+ strcpy(env_block_pos, env[e]);
+ env_block_pos += strlen(env_block_pos) + 1;
+ }
- *env_block_pos = 0; /* environment block is terminated by a double null */
+ *env_block_pos = 0; /* environment block is terminated by a double null */
+ } else
+ env_block = NULL;
status = DosExecPgm(error_object, sizeof(error_object),
attr->detached ? EXEC_BACKGROUND : EXEC_ASYNC,