apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r170398 - /apr/apr/branches/0.9.x/threadproc/unix/proc.c
Date Mon, 16 May 2005 15:10:06 GMT
Author: jorton
Date: Mon May 16 08:10:05 2005
New Revision: 170398

URL: http://svn.apache.org/viewcvs?rev=170398&view=rev
Log:
Merge r170395 from trunk:

* 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).

Modified:
    apr/apr/branches/0.9.x/threadproc/unix/proc.c

Modified: apr/apr/branches/0.9.x/threadproc/unix/proc.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/threadproc/unix/proc.c?rev=170398&r1=170397&r2=170398&view=diff
==============================================================================
--- apr/apr/branches/0.9.x/threadproc/unix/proc.c (original)
+++ apr/apr/branches/0.9.x/threadproc/unix/proc.c Mon May 16 08:10:05 2005
@@ -109,16 +109,18 @@
                                                     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;
 }
 
 
@@ -126,16 +128,18 @@
                                                      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;
 }
 
 
@@ -143,16 +147,18 @@
                                                      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;
 }
 
 



Mime
View raw message