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

Consistently present absent stdio handles on Windows as NULL handles. #93263

Merged

Commits on Mar 4, 2022

  1. Consistently present absent stdio handles on Windows as NULL handles.

    This addresses rust-lang#90964 by making the std API consistent about presenting
    absent stdio handles on Windows as NULL handles. Stdio handles may be
    absent due to `#![windows_subsystem = "windows"]`, due to the console
    being detached, or due to a child process having been launched from a
    parent where stdio handles are absent.
    
    Specifically, this fixes the case of child processes of parents with absent
    stdio, which previously ended up with `stdin().as_raw_handle()` returning
    `INVALID_HANDLE_VALUE`, which was surprising, and which overlapped with an
    unrelated valid handle value. With this patch, `stdin().as_raw_handle()`
    now returns null in these situation, which is consistent with what it
    does in the parent process.
    
    And, document this in the "Windows Portability Considerations" sections of
    the relevant documentation.
    sunfishcode committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    ee02f01 View commit details
    Browse the repository at this point in the history
  2. Fix a compilation error.

    sunfishcode committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    7dd3246 View commit details
    Browse the repository at this point in the history
  3. Remove redundant code for handling NULL handles on Windows.

    Before calling `CreateProcessW`, stdio handles are passed through
    `stdio::get_handle`, which already converts NULL to
    `INVALID_HANDLE_VALUE`, so we don't need extra checks for NULL after
    that point.
    sunfishcode committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    7ddf41c View commit details
    Browse the repository at this point in the history