apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/file_io/unix filedup.c
Date Sat, 22 Mar 2003 02:33:50 GMT
wrowe       2003/03/21 18:33:50

  Modified:    file_io/unix filedup.c
  Log:
    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.
  
  Revision  Changes    Path
  1.63      +6 -12     apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/filedup.c,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- filedup.c	22 Mar 2003 02:30:42 -0000	1.62
  +++ filedup.c	22 Mar 2003 02:33:50 -0000	1.63
  @@ -119,23 +119,17 @@
           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;
   }
  
  
  

Mime
View raw message