summaryrefslogtreecommitdiff
path: root/threadproc/os2
diff options
context:
space:
mode:
authorbjh <bjh@13f79535-47bb-0310-9956-ffa450edef68>2000-05-25 03:05:27 +0000
committerbjh <bjh@13f79535-47bb-0310-9956-ffa450edef68>2000-05-25 03:05:27 +0000
commitfff5640543eb750e0fea86b078ca23ef816b4072 (patch)
tree15369b204c54ee3bbae7a6c0346890d279966828 /threadproc/os2
parentd1b9dcab41778fa27f0fd86775472c97a51c3ab1 (diff)
downloadlibapr-fff5640543eb750e0fea86b078ca23ef816b4072.tar.gz
OS/2: Adapt to new ap_proc_t type & add missing ap_setprocattr_child*
functions. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@60097 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc/os2')
-rw-r--r--threadproc/os2/proc.c112
-rw-r--r--threadproc/os2/threadproc.h7
2 files changed, 65 insertions, 54 deletions
diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c
index 6fc0f755a..acfd80f63 100644
--- a/threadproc/os2/proc.c
+++ b/threadproc/os2/proc.c
@@ -144,6 +144,54 @@ ap_status_t ap_setprocattr_io(ap_procattr_t *attr, ap_int32_t in,
return APR_SUCCESS;
}
+ap_status_t ap_setprocattr_childin(ap_procattr_t *attr, ap_file_t *child_in,
+ ap_file_t *parent_in)
+{
+ if (attr->child_in == NULL && attr->parent_in == NULL)
+ ap_create_pipe(&attr->child_in, &attr->parent_in, attr->cntxt);
+
+ if (child_in != NULL)
+ ap_dupfile(&attr->child_in, child_in, attr->cntxt);
+
+ if (parent_in != NULL)
+ ap_dupfile(&attr->parent_in, parent_in, attr->cntxt);
+
+ return APR_SUCCESS;
+}
+
+
+ap_status_t ap_setprocattr_childout(ap_procattr_t *attr, ap_file_t *child_out,
+ ap_file_t *parent_out)
+{
+ if (attr->child_out == NULL && attr->parent_out == NULL)
+ ap_create_pipe(&attr->child_out, &attr->parent_out, attr->cntxt);
+
+ if (child_out != NULL)
+ ap_dupfile(&attr->child_out, child_out, attr->cntxt);
+
+ if (parent_out != NULL)
+ ap_dupfile(&attr->parent_out, parent_out, attr->cntxt);
+
+ return APR_SUCCESS;
+}
+
+
+ap_status_t ap_setprocattr_childerr(ap_procattr_t *attr, ap_file_t *child_err,
+ ap_file_t *parent_err)
+{
+ if (attr->child_err == NULL && attr->parent_err == NULL)
+ ap_create_pipe(&attr->child_err, &attr->parent_err, attr->cntxt);
+
+ if (child_err != NULL)
+ ap_dupfile(&attr->child_err, child_err, attr->cntxt);
+
+ if (parent_err != NULL)
+ ap_dupfile(&attr->parent_err, parent_err, attr->cntxt);
+
+ return APR_SUCCESS;
+}
+
+
ap_status_t ap_setprocattr_dir(ap_procattr_t *attr, const char *dir)
{
attr->currdir = ap_pstrdup(attr->cntxt, dir);
@@ -166,24 +214,24 @@ ap_status_t ap_setprocattr_detach(ap_procattr_t *attr, ap_int32_t detach)
return APR_SUCCESS;
}
-ap_status_t ap_fork(ap_proc_t **proc, ap_pool_t *cont)
+ap_status_t ap_fork(ap_proc_t *proc, ap_pool_t *cont)
{
int pid;
- (*proc) = ap_palloc(cont, sizeof(ap_proc_t));
-
if ((pid = fork()) < 0) {
return errno;
- } else if (pid == 0) {
- (*proc)->pid = pid;
- (*proc)->attr = NULL;
- (*proc)->running = TRUE;
+ }
+ else if (pid == 0) {
+ proc->pid = pid;
+ proc->in = NULL;
+ proc->out = NULL;
+ proc->err = NULL;
return APR_INCHILD;
}
-
- (*proc)->pid = pid;
- (*proc)->attr = NULL;
- (*proc)->running = TRUE;
+ proc->pid = pid;
+ proc->in = NULL;
+ proc->out = NULL;
+ proc->err = NULL;
return APR_INPARENT;
}
@@ -217,7 +265,7 @@ static char *double_quotes(ap_pool_t *cntxt, char *str)
-ap_status_t ap_create_process(ap_proc_t **new, const char *progname,
+ap_status_t ap_create_process(ap_proc_t *proc, const char *progname,
char *const args[], char **env,
ap_procattr_t *attr, ap_pool_t *cont)
{
@@ -235,15 +283,6 @@ ap_status_t ap_create_process(ap_proc_t **new, const char *progname,
char *env_block, *env_block_pos;
RESULTCODES rescodes;
- (*new) = (ap_proc_t *)ap_palloc(cont, sizeof(ap_proc_t));
-
- if ((*new) == NULL) {
- return APR_ENOMEM;
- }
-
- (*new)->cntxt = cont;
- (*new)->running = FALSE;
-
/* Prevent other threads from running while these process-wide resources are modified */
if (attr->child_in || attr->child_out || attr->child_err || attr->currdir) {
criticalsection = TRUE;
@@ -402,7 +441,7 @@ ap_status_t ap_create_process(ap_proc_t **new, const char *progname,
attr->detached ? EXEC_BACKGROUND : EXEC_ASYNCRESULT,
cmdline, env_block, &rescodes, cmdline);
- (*new)->pid = rescodes.codeTerminate;
+ proc->pid = rescodes.codeTerminate;
if (attr->currdir != NULL) {
chdir(savedir);
@@ -432,32 +471,15 @@ ap_status_t ap_create_process(ap_proc_t **new, const char *progname,
if (criticalsection)
DosExitCritSec();
- (*new)->attr = attr;
- (*new)->running = status == APR_SUCCESS;
+ proc->in = attr->parent_in;
+ proc->err = attr->parent_err;
+ proc->out = attr->parent_out;
return status;
}
-ap_status_t ap_get_childin(ap_file_t **new, ap_proc_t *proc)
-{
- (*new) = proc->attr->parent_in;
- return APR_SUCCESS;
-}
-
-ap_status_t ap_get_childout(ap_file_t **new, ap_proc_t *proc)
-{
- (*new) = proc->attr->parent_out;
- return APR_SUCCESS;
-}
-
-ap_status_t ap_get_childerr(ap_file_t **new, ap_proc_t *proc)
-{
- (*new) = proc->attr->parent_err;
- return APR_SUCCESS;
-}
-
-ap_status_t ap_wait_proc(ap_proc_t *proc,
+ap_status_t ap_wait_proc(ap_proc_t *proc,
ap_wait_how_e wait)
{
RESULTCODES codes;
@@ -467,13 +489,9 @@ ap_status_t ap_wait_proc(ap_proc_t *proc,
if (!proc)
return APR_ENOPROC;
- if (!proc->running)
- return APR_CHILD_DONE;
-
rc = DosWaitChild(DCWA_PROCESS, wait == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, proc->pid);
if (rc == 0) {
- proc->running = 0;
return APR_CHILD_DONE;
} else if (rc == ERROR_CHILD_NOT_COMPLETE) {
return APR_CHILD_NOTDONE;
diff --git a/threadproc/os2/threadproc.h b/threadproc/os2/threadproc.h
index cfcca8d62..d6971dbb3 100644
--- a/threadproc/os2/threadproc.h
+++ b/threadproc/os2/threadproc.h
@@ -95,13 +95,6 @@ struct ap_procattr_t {
ap_int32_t detached;
};
-struct ap_proc_t {
- ap_pool_t *cntxt;
- pid_t pid;
- struct ap_procattr_t *attr;
- int running;
-};
-
typedef void (*os2_thread_start_t)(void *);
#endif /* ! THREAD_PROC_H */