Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 21841 invoked from network); 14 Oct 2007 18:01:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Oct 2007 18:01:01 -0000 Received: (qmail 87457 invoked by uid 500); 14 Oct 2007 18:00:48 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 87406 invoked by uid 500); 14 Oct 2007 18:00:48 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 87395 invoked by uid 99); 14 Oct 2007 18:00:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Oct 2007 11:00:48 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Oct 2007 18:01:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AEE151A9832; Sun, 14 Oct 2007 11:00:39 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r584570 - /apr/apr/trunk/threadproc/unix/proc.c Date: Sun, 14 Oct 2007 18:00:39 -0000 To: commits@apr.apache.org From: wrowe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071014180039.AEE151A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: wrowe Date: Sun Oct 14 11:00:37 2007 New Revision: 584570 URL: http://svn.apache.org/viewvc?rev=584570&view=rev Log: Here's my recommendation; upon opening the pipes, always set the parent-end of the pipe to uninherited. Let it be closed upon cleanup_for_exec. The later dup2() for the parent pipe does not automagically become inherited again, and later dup()'s are never inherited by default. There's no longer an explicit need to close the parent-end in proc_create Modified: apr/apr/trunk/threadproc/unix/proc.c Modified: apr/apr/trunk/threadproc/unix/proc.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/unix/proc.c?rev=584570&r1=584569&r2=584570&view=diff ============================================================================== --- apr/apr/trunk/threadproc/unix/proc.c (original) +++ apr/apr/trunk/threadproc/unix/proc.c Sun Oct 14 11:00:37 2007 @@ -58,7 +58,9 @@ in = APR_WRITE_BLOCK; if ((rv = apr_file_pipe_create_ex(&attr->child_in, &attr->parent_in, - in, attr->pool)) != APR_SUCCESS) + in, attr->pool)) == APR_SUCCESS) + rv = apr_file_inherit_unset(attr->parent_in); + if (rv != APR_SUCCESS) return rv; } else if (in == APR_NO_FILE) @@ -66,7 +68,9 @@ if ((out != APR_NO_PIPE) && (out != APR_NO_FILE)) { if ((rv = apr_file_pipe_create_ex(&attr->parent_out, &attr->child_out, - out, attr->pool)) != APR_SUCCESS) + out, attr->pool)) == APR_SUCCESS) + rv = apr_file_inherit_unset(attr->parent_out); + if (rv != APR_SUCCESS) return rv; } else if (out == APR_NO_FILE) @@ -75,6 +79,8 @@ if ((err != APR_NO_PIPE) && (err != APR_NO_FILE)) { if ((rv = apr_file_pipe_create_ex(&attr->parent_err, &attr->child_err, err, attr->pool)) != APR_SUCCESS) + rv = apr_file_inherit_unset(attr->parent_err); + if (rv != APR_SUCCESS) return rv; } else if (err == APR_NO_FILE) @@ -92,9 +98,10 @@ if (attr->child_in == NULL && attr->parent_in == NULL && child_in == NULL && parent_in == NULL) - rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, - attr->pool); - + if ((rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, + attr->pool)) == APR_SUCCESS) + rv = apr_file_inherit_unset(attr->parent_in); + if (child_in != NULL && rv == APR_SUCCESS) { if (attr->child_in && (attr->child_in->filedes != -1)) rv = apr_file_dup2(attr->child_in, child_in, attr->pool); @@ -125,8 +132,9 @@ if (attr->child_out == NULL && attr->parent_out == NULL && child_out == NULL && parent_out == NULL) - rv = apr_file_pipe_create(&attr->parent_out, &attr->child_out, - attr->pool); + if ((rv = apr_file_pipe_create(&attr->parent_out, &attr->child_out, + attr->pool)) == APR_SUCCESS) + rv = apr_file_inherit_unset(attr->parent_out); if (child_out != NULL && rv == APR_SUCCESS) { if (attr->child_out && (attr->child_out->filedes != -1)) @@ -158,8 +166,9 @@ if (attr->child_err == NULL && attr->parent_err == NULL && child_err == NULL && parent_err == NULL) - rv = apr_file_pipe_create(&attr->parent_err, &attr->child_err, - attr->pool); + if ((rv = apr_file_pipe_create(&attr->parent_err, &attr->child_err, + attr->pool)) == APR_SUCCESS) + rv = apr_file_inherit_unset(attr->parent_err); if (child_err != NULL && rv == APR_SUCCESS) { if (attr->child_err && (attr->child_err->filedes != -1)) @@ -424,8 +433,6 @@ close(STDIN_FILENO); } else if (attr->child_in) { - if (attr->parent_in) - apr_file_close(attr->parent_in); dup2(attr->child_in->filedes, STDIN_FILENO); apr_file_close(attr->child_in); } @@ -434,8 +441,6 @@ close(STDOUT_FILENO); } else if (attr->child_out) { - if (attr->parent_out) - apr_file_close(attr->parent_out); dup2(attr->child_out->filedes, STDOUT_FILENO); apr_file_close(attr->child_out); } @@ -444,8 +449,6 @@ close(STDERR_FILENO); } else if (attr->child_err) { - if (attr->parent_err) - apr_file_close(attr->parent_err); dup2(attr->child_err->filedes, STDERR_FILENO); apr_file_close(attr->child_err); }