Skip to content

Killing cargo test doesn't terminate the child process #14929

Open
@fredrik-jansson-se

Description

@fredrik-jansson-se

Problem

I'm using bacon to run tests and when tests are restarted, bacon terminates the child (cargo test) process using SIGKILL. The problem is if the test doesn't terminate, the child process is not terminated.

NOTE, this is not bacon related but can be reproduced using cargo only.

#[test]
fn test() {
    loop {
        std::thread::sleep_ms(10_0000);
    }
}

I can reproduce this on both MacOS and Linux.

Steps

  1. Create a main.rs with a test that hangs, see above
  2. pkill -9 cargo
  3. ps aux | grep
  4. You'll find that the child process is still running (/home/frja/bacon-zombie/target/debug/deps/bacon_zombie-ab96b146d87eb3ef)

Possible Solution(s)

Not sure if it's possible to link the spawned child process... process groups maybe?

Notes

No response

Version

cargo 1.83.0 (5ffbef321 2024-10-29)
release: 1.83.0
commit-hash: 5ffbef3211a8c378857905775a15c5b32a174d3b
commit-date: 2024-10-29
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Ubuntu 24.4.0 (noble) [64-bit]



cargo 1.83.0 (5ffbef321 2024-10-29)
release: 1.83.0
commit-hash: 5ffbef3211a8c378857905775a15c5b32a174d3b
commit-date: 2024-10-29
host: aarch64-apple-darwin
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.7.1 (sys:0.4.74+curl-8.9.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 15.1.1 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugCommand-testS-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fixS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions