Skip to content

Child::kill will not terminate children on Linux #115241

Open
@cottnn

Description

@cottnn

Location

https://doc.rust-lang.org/std/process/struct.Child.html#method.kill

Summary

Documentation for Child::kill in standard library should include a note that the signal won't be sent to any children of the process, only to the process itself (at least on Linux).

This can be confusing because people might expect that Child::kill will terminate the process completely, including it's children.

I think the proper way to kill the process and it's children is to send the signal to the process group

https://linux.die.net/man/2/killpg
https://linux.die.net/man/2/kill

Edit: Standard library includes Command::process_group method. .process_group(0) will set child's process group to it's PID. After spawning the command, it will be possible to call kill(-pid, SIGKILL), which will terminate the child and all it's children

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-processArea: `std::process` and `std::env`T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions