summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2003-03-22 02:33:50 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2003-03-22 02:33:50 +0000
commit39d6b5189340cbedfe5068c9129b156733f5330e (patch)
tree02295b920249cd70e58f0257984606b6b0acad97
parentefc746506079540bff6ea7b8bd7dc44f79a5a268 (diff)
downloadlibapr-39d6b5189340cbedfe5068c9129b156733f5330e.tar.gz
Revert my recent change that concerns both Jeff Trawick and myself,
we will make no presumtion that fd 0..2 are special cases from apr_file_dup(), and remain uninherited as in the previous release of APR. Although it's a common Unix construct to; close(2) fd = dup(2, x) it's certainly not portable and shouldn't be encouraged. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64442 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--file_io/unix/filedup.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/file_io/unix/filedup.c b/file_io/unix/filedup.c
index 6997ff238..34ca7de82 100644
--- a/file_io/unix/filedup.c
+++ b/file_io/unix/filedup.c
@@ -119,23 +119,17 @@ static apr_status_t _file_dup(apr_file_t **new_file,
return APR_SUCCESS;
}
- /* apr_file_dup() clears the inherit attribute for normal files,
- * but sets the inherit attribute for std[out,in,err] fd's.
- * The user must call apr_file_inherit_[un]set() on the dupped
+ /* apr_file_dup() retains all old_file flags with the exceptions
+ * of APR_INHERIT and APR_FILE_NOCLEANUP.
+ * The user must call apr_file_inherit_set() on the dupped
* apr_file_t when desired.
*/
- if ((*new_file)->filedes <= 2) {
- (*new_file)->flags = old_file->flags | APR_INHERIT;
- }
- else {
- (*new_file)->flags = old_file->flags & ~APR_INHERIT;
- }
+ (*new_file)->flags = old_file->flags
+ & ~(APR_INHERIT | APR_FILE_NOCLEANUP);
apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file),
apr_unix_file_cleanup,
- ((*new_file)->flags & APR_INHERIT)
- ? apr_pool_cleanup_null
- : apr_unix_file_cleanup);
+ apr_unix_file_cleanup);
return APR_SUCCESS;
}