summaryrefslogtreecommitdiff
path: root/threadproc/unix
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-05-16 15:07:38 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-05-16 15:07:38 +0000
commit66790b3a1f06736b96188887c6706085ba58d35d (patch)
treeb4d2538d73b3021f17856c2dacb3875188054ec6 /threadproc/unix
parent3c462b711e5a7049e073f659449766f8666e2bf4 (diff)
downloadlibapr-66790b3a1f06736b96188887c6706085ba58d35d.tar.gz
* threadproc/unix/proc.c (apr_procattr_child_in_set,
apr_procattr_child_out_set, apr_procattr_child_err_set): Add error checking: fixes segfaults in applications when pipe() or dup2() fail (e.g. due to ulimit settings). git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@170395 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc/unix')
-rw-r--r--threadproc/unix/proc.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c
index 08e4a8d57..ce32b09bf 100644
--- a/threadproc/unix/proc.c
+++ b/threadproc/unix/proc.c
@@ -111,16 +111,18 @@ APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr,
apr_file_t *child_in,
apr_file_t *parent_in)
{
- if (attr->child_in == NULL && attr->parent_in == NULL)
- apr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool);
+ apr_status_t rv = APR_SUCCESS;
- if (child_in != NULL)
- apr_file_dup2(attr->child_in, child_in, attr->pool);
+ if (attr->child_in == NULL && attr->parent_in == NULL)
+ rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool);
+
+ if (child_in != NULL && rv == APR_SUCCESS)
+ rv = apr_file_dup2(attr->child_in, child_in, attr->pool);
- if (parent_in != NULL)
- apr_file_dup2(attr->parent_in, parent_in, attr->pool);
+ if (parent_in != NULL && rv == APR_SUCCESS)
+ rv = apr_file_dup2(attr->parent_in, parent_in, attr->pool);
- return APR_SUCCESS;
+ return rv;
}
@@ -128,16 +130,18 @@ APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr,
apr_file_t *child_out,
apr_file_t *parent_out)
{
+ apr_status_t rv = APR_SUCCESS;
+
if (attr->child_out == NULL && attr->parent_out == NULL)
- apr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool);
+ rv = apr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool);
- if (child_out != NULL)
- apr_file_dup2(attr->child_out, child_out, attr->pool);
+ if (child_out != NULL && rv == APR_SUCCESS)
+ rv = apr_file_dup2(attr->child_out, child_out, attr->pool);
- if (parent_out != NULL)
- apr_file_dup2(attr->parent_out, parent_out, attr->pool);
+ if (parent_out != NULL && rv == APR_SUCCESS)
+ rv = apr_file_dup2(attr->parent_out, parent_out, attr->pool);
- return APR_SUCCESS;
+ return rv;
}
@@ -145,16 +149,18 @@ APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr,
apr_file_t *child_err,
apr_file_t *parent_err)
{
+ apr_status_t rv = APR_SUCCESS;
+
if (attr->child_err == NULL && attr->parent_err == NULL)
- apr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool);
+ rv = apr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool);
- if (child_err != NULL)
- apr_file_dup2(attr->child_err, child_err, attr->pool);
+ if (child_err != NULL && rv == APR_SUCCESS)
+ rv = apr_file_dup2(attr->child_err, child_err, attr->pool);
- if (parent_err != NULL)
- apr_file_dup2(attr->parent_err, parent_err, attr->pool);
+ if (parent_err != NULL && rv == APR_SUCCESS)
+ rv = apr_file_dup2(attr->parent_err, parent_err, attr->pool);
- return APR_SUCCESS;
+ return rv;
}