Skip to content

"blocking waitpid returned pid=0" from AsyncGroupChild::wait #21

@9999years

Description

@9999years

Seems to be a cancel safety issue, this happens when i wait() with a timeout and then wait() again:

This reproducer:

use command_group::AsyncCommandGroup;
use tokio::process::Command;

#[tokio::main]
async fn main() {
    let mut group = Command::new("sh")
        .arg("-c")
        .arg("sleep 30; echo done!")
        .group_spawn()
        .unwrap();
    println!("spawned");

    match tokio::time::timeout(std::time::Duration::from_secs(1), group.wait()).await {
        Ok(res) => {
            println!("command exited or waiting failed: {res:?}");
        }
        Err(_) => {
            println!("command took too long");
        }
    }

    group.kill().unwrap();
    println!("killed");
    group.wait().await.unwrap();
    println!("finished waiting");
}

Prints this on my machine:

spawned
command took too long
killed
thread 'main' panicked at src/main.rs:26:24:
called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "blocking waitpid returned pid=0" }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions