Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 11942 invoked from network); 14 Oct 2007 17:36:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Oct 2007 17:36:40 -0000 Received: (qmail 54793 invoked by uid 500); 14 Oct 2007 17:36:28 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 54679 invoked by uid 500); 14 Oct 2007 17:36:28 -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 54668 invoked by uid 99); 14 Oct 2007 17:36:28 -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 10:36:28 -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 17:36:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 92BBC1A9832; Sun, 14 Oct 2007 10:35:49 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r584569 - /apr/apr/trunk/threadproc/unix/proc.c Date: Sun, 14 Oct 2007 17:35:49 -0000 To: commits@apr.apache.org From: wrowe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071014173549.92BBC1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: wrowe Date: Sun Oct 14 10:35:48 2007 New Revision: 584569 URL: http://svn.apache.org/viewvc?rev=584569&view=rev Log: apr_file_dup() varies from dup2 by not setting the child handle as inherited. Solve this by setting the duplicated handle to inherit. once finished with the fork(), now that we don't waste pipe creation resources on a single handle, watch out for closing the parent handle inside the child. in fact I believe that toggling parent_* handles apr_file_inherit_unset way back in apr_procattr_io_set / apr_procattr_child_*_set would be more efficient; comments? 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=584569&r1=584568&r2=584569&view=diff ============================================================================== --- apr/apr/trunk/threadproc/unix/proc.c (original) +++ apr/apr/trunk/threadproc/unix/proc.c Sun Oct 14 10:35:48 2007 @@ -92,13 +92,18 @@ 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); + rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, + attr->pool); 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); - else - rv = apr_file_dup(&attr->child_in, child_in, attr->pool); + else { + attr->child_in = NULL; + if ((rv = apr_file_dup(&attr->child_in, child_in, attr->pool)) + == APR_SUCCESS) + rv = apr_file_inherit_set(attr->child_in); + } } if (parent_in != NULL && rv == APR_SUCCESS) { @@ -120,13 +125,18 @@ if (attr->child_out == NULL && attr->parent_out == NULL && child_out == NULL && parent_out == NULL) - rv = apr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); + rv = apr_file_pipe_create(&attr->parent_out, &attr->child_out, + attr->pool); if (child_out != NULL && rv == APR_SUCCESS) { if (attr->child_out && (attr->child_out->filedes != -1)) rv = apr_file_dup2(attr->child_out, child_out, attr->pool); - else - rv = apr_file_dup(&attr->child_out, child_out, attr->pool); + else { + attr->child_out = NULL; + if ((rv = apr_file_dup(&attr->child_out, child_out, attr->pool)) + == APR_SUCCESS) + rv = apr_file_inherit_set(attr->child_out); + } } if (parent_out != NULL && rv == APR_SUCCESS) { @@ -148,13 +158,18 @@ if (attr->child_err == NULL && attr->parent_err == NULL && child_err == NULL && parent_err == NULL) - rv = apr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); + rv = apr_file_pipe_create(&attr->parent_err, &attr->child_err, + attr->pool); if (child_err != NULL && rv == APR_SUCCESS) { if (attr->child_err && (attr->child_err->filedes != -1)) rv = apr_file_dup2(attr->child_err, child_err, attr->pool); - else - rv = apr_file_dup(&attr->child_err, child_err, attr->pool); + else { + attr->child_err = NULL; + if ((rv = apr_file_dup(&attr->child_err, child_err, attr->pool)) + == APR_SUCCESS) + rv = apr_file_inherit_set(attr->child_err); + } } if (parent_err != NULL && rv == APR_SUCCESS) { if (attr->parent_err) @@ -409,7 +424,8 @@ close(STDIN_FILENO); } else if (attr->child_in) { - apr_file_close(attr->parent_in); + if (attr->parent_in) + apr_file_close(attr->parent_in); dup2(attr->child_in->filedes, STDIN_FILENO); apr_file_close(attr->child_in); } @@ -418,7 +434,8 @@ close(STDOUT_FILENO); } else if (attr->child_out) { - apr_file_close(attr->parent_out); + if (attr->parent_out) + apr_file_close(attr->parent_out); dup2(attr->child_out->filedes, STDOUT_FILENO); apr_file_close(attr->child_out); } @@ -427,7 +444,8 @@ close(STDERR_FILENO); } else if (attr->child_err) { - apr_file_close(attr->parent_err); + if (attr->parent_err) + apr_file_close(attr->parent_err); dup2(attr->child_err->filedes, STDERR_FILENO); apr_file_close(attr->child_err); }