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

feature(process): Use pidfd on Linux for tokio::process::Child::wait #6152

Merged
merged 17 commits into from
Jan 11, 2024

Commits on Dec 31, 2023

  1. feat(process) pidfd: Implement initial PidfdReaper impl

    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    d3b6551 View commit details
    Browse the repository at this point in the history
  2. Use PidfdReaper in unix::Child if possible

    fallback to signal-based `Reaper` if pidfd cannot be created.
    
    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    106d9c8 View commit details
    Browse the repository at this point in the history
  3. Fix compilation on non-linux targets

    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    a3945d0 View commit details
    Browse the repository at this point in the history
  4. Add testing for pidfd_reaper

    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    c6a869f View commit details
    Browse the repository at this point in the history
  5. Fix running tests in pidfd_reaper

    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    5f62be6 View commit details
    Browse the repository at this point in the history
  6. Disable pidfd_reaper test for miri

    Since miri does not support process spawning
    
    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    92bef5a View commit details
    Browse the repository at this point in the history
  7. Skip pidfd testing on unsupported linux kernel

    Only Linux kernel >= 5.10 support pidfd
    
    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    80a1cd7 View commit details
    Browse the repository at this point in the history
  8. Optimization: Skip pidfd_open if last call failed with ENOSYS

    And fixed `test::is_pidfd_available`
    
    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    c38faca View commit details
    Browse the repository at this point in the history
  9. Fix PidfdReaper::drop: do not spawn any task there

    To avoid potential headaches such as:
    
     - The drop being run outside of a Tokio runtime context
     - The runtime being present but not actually running
    
    Since this is the initial implementation, I chose to use the
    `OrphanQueue` also used by the signal-driven `Reaper` impl.
    
    It's simple and easy to implement without having to add runtime driver
    and guaranteed to work.
    
    Further improvement can be done on the basis of this PR.
    
    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    3b89981 View commit details
    Browse the repository at this point in the history

Commits on Jan 9, 2024

  1. Only pull in PidfdReaper if feature rt is enabled on Linux

    Instead of automatically enabling feature `rt` if `process` is enabled,
    even if the target os is not `linux`.
    
    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    bf14726 View commit details
    Browse the repository at this point in the history
  2. Add test process_spawned_outside_runtime

    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    523117a View commit details
    Browse the repository at this point in the history
  3. Add process_spawned_and_wait_in_different_runtime

    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    66a2f4e View commit details
    Browse the repository at this point in the history

Commits on Jan 10, 2024

  1. Configuration menu
    Copy the full SHA
    ef05617 View commit details
    Browse the repository at this point in the history
  2. Improve safety comments in Pidfd::open

    Also remove invocation of one `unsafe` function `errno_location`.
    
    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    e89a5ec View commit details
    Browse the repository at this point in the history
  3. Refactor <PidfdReaperInner as Future>::poll

    Move `err.kind() == io::ErrorKind::Other` checking into
    `is_rt_shutdown_err`
    
    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    f093c44 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7ee4509 View commit details
    Browse the repository at this point in the history

Commits on Jan 11, 2024

  1. Fix leaked sleep process in test_pidfd_reaper_drop

    Signed-off-by: Jiahao XU <[email protected]>
    NobodyXu committed Jan 11, 2024
    Configuration menu
    Copy the full SHA
    dc889e3 View commit details
    Browse the repository at this point in the history