Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish atomically setting CLOEXEC for fds created on Unix #31417

Merged
merged 6 commits into from
Feb 6, 2016

Commits on Feb 6, 2016

  1. std: Only have extra set_cloexec for files on Linux

    On Linux we have to do this for binary compatibility with 2.6.18, but for other
    OSes (e.g. OSX/BSDs/etc) they all support this flag so we don't need to pass it.
    alexcrichton committed Feb 6, 2016
    Configuration menu
    Copy the full SHA
    64d7eca View commit details
    Browse the repository at this point in the history
  2. std: When duplicating fds, skip extra set_cloexec

    Similar to the previous commit, if `F_DUPFD_CLOEXEC` succeeds then there's no
    need for us to then call `set_cloexec` on platforms other than Linux. The bug
    mentioned of kernels not actually setting the `CLOEXEC` flag has only been
    repored on Linux, not elsewhere.
    alexcrichton committed Feb 6, 2016
    Configuration menu
    Copy the full SHA
    0fff73b View commit details
    Browse the repository at this point in the history
  3. std: Atomically set CLOEXEC for sockets if possible

    This commit adds support for creating sockets with the `SOCK_CLOEXEC` flag.
    Support for this flag was added in Linux 2.6.27, however, and support does not
    exist on platforms other than Linux. For this reason we still have the same
    fallback as before but just special case Linux if we can.
    alexcrichton committed Feb 6, 2016
    Configuration menu
    Copy the full SHA
    1bd2d20 View commit details
    Browse the repository at this point in the history
  4. std: Add a helper for symbols that may not exist

    Right now we only attempt to call one symbol which my not exist everywhere,
    __pthread_get_minstack, but this pattern will come up more often as we start to
    bind newer functionality of systems like Linux.
    
    Take a similar strategy as the Windows implementation where we use `dlopen` to
    lookup whether a symbol exists or not.
    alexcrichton committed Feb 6, 2016
    Configuration menu
    Copy the full SHA
    1a31e1c View commit details
    Browse the repository at this point in the history
  5. std: Add support for accept4 on Linux

    This is necessary to atomically accept a socket and set the CLOEXEC flag at the
    same time. Support only appeared in Linux 2.6.28 so we have to dynamically
    determine which syscall we're supposed to call in this case.
    alexcrichton committed Feb 6, 2016
    Configuration menu
    Copy the full SHA
    4631518 View commit details
    Browse the repository at this point in the history
  6. std: Try to use pipe2 on Linux for pipes

    This commit attempts to use the `pipe2` syscall on Linux to atomically set the
    CLOEXEC flag for pipes created. Unfortunately this was added in 2.6.27 so we
    have to dynamically determine whether we can use it or not.
    
    This commit also updates the `fds-are-cloexec.rs` test to test stdio handles for
    spawned processes as well.
    alexcrichton committed Feb 6, 2016
    Configuration menu
    Copy the full SHA
    812b309 View commit details
    Browse the repository at this point in the history