summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsf <sf@13f79535-47bb-0310-9956-ffa450edef68>2011-10-15 21:05:28 +0000
committersf <sf@13f79535-47bb-0310-9956-ffa450edef68>2011-10-15 21:05:28 +0000
commit8247f0a57383458f84791c434bb1a6c0c8632d23 (patch)
treef4f3884af65e172a8cc813bb467c3272b42834d1
parent9cdbe3d4f179e0a99173d1acba515b57d6931bdd (diff)
downloadlibapr-8247f0a57383458f84791c434bb1a6c0c8632d23.tar.gz
Backport r1183685:
Don't close any of the new stdin/stdout/stderr FDs in the child if it already has the correct FD. PR: 51995 Submitted by: Dan Ports <drkp csail mit edu>] git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@1183708 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES4
-rw-r--r--threadproc/unix/proc.c9
2 files changed, 10 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index c7c72f863..00613cddc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes for APR 1.4.6
+ *) apr_proc_create: Don't close any of the new stdin/stdout/stderr in the
+ child if it already has the correct FD. PR 51995.
+ [Dan Ports <drkp csail mit edu>]
+
*) Fix flag character '#' in combination with format character 'x' in
apr snprintf implementations. [Rainer Jung]
diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c
index b5e4dd47c..e5a3df9b4 100644
--- a/threadproc/unix/proc.c
+++ b/threadproc/unix/proc.c
@@ -432,7 +432,8 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
if ((attr->child_in) && (attr->child_in->filedes == -1)) {
close(STDIN_FILENO);
}
- else if (attr->child_in) {
+ else if (attr->child_in &&
+ attr->child_in->filedes != STDIN_FILENO) {
dup2(attr->child_in->filedes, STDIN_FILENO);
apr_file_close(attr->child_in);
}
@@ -440,7 +441,8 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
if ((attr->child_out) && (attr->child_out->filedes == -1)) {
close(STDOUT_FILENO);
}
- else if (attr->child_out) {
+ else if (attr->child_out &&
+ attr->child_out->filedes != STDOUT_FILENO) {
dup2(attr->child_out->filedes, STDOUT_FILENO);
apr_file_close(attr->child_out);
}
@@ -448,7 +450,8 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
if ((attr->child_err) && (attr->child_err->filedes == -1)) {
close(STDERR_FILENO);
}
- else if (attr->child_err) {
+ else if (attr->child_err &&
+ attr->child_err->filedes != STDERR_FILENO) {
dup2(attr->child_err->filedes, STDERR_FILENO);
apr_file_close(attr->child_err);
}