Skip to content

Commit

Permalink
Revert my recent change that concerns both Jeff Trawick and myself,
Browse files Browse the repository at this point in the history
  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: https://svn.apache.org/repos/asf/apr/apr/trunk@64442 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
wrowe committed Mar 22, 2003
1 parent d3b0a6e commit 2ba1e83
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions file_io/unix/filedup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2ba1e83

Please sign in to comment.