• A
    std: Set CLOEXEC for all fds opened on unix · d6c72306
    Alex Crichton 提交于
    This commit starts to set the CLOEXEC flag for all files and sockets opened by
    the standard library by default on all unix platforms. There are a few points of
    note in this commit:
    
    * The implementation is not 100% satisfactory in the face of threads. File
      descriptors only have the `F_CLOEXEC` flag set *after* they are opened,
      allowing for a fork/exec to happen in the middle and leak the descriptor.
      Some platforms do support atomically opening a descriptor while setting the
      `CLOEXEC` flag, and it is left as a future extension to bind these apis as it
      is unclear how to do so nicely at this time.
    
    * The implementation does not offer a method of opting into the old behavior of
      not setting `CLOEXEC`. This will possibly be added in the future through
      extensions on `OpenOptions`, for example.
    
    * This change does not yet audit any Windows APIs to see if the handles are
      inherited by default by accident.
    
    This is a breaking change for users who call `fork` or `exec` outside of the
    standard library itself and expect file descriptors to be inherted. All file
    descriptors created by the standard library will no longer be inherited.
    
    [breaking-change]
    d6c72306
pipe2.rs 1.4 KB