diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f0a8da..a803aa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next (YYYY-MM-DD) +- Add `ErasedChild::id()` method. + ## v4.0.0 (2023-11-05) - Clarify why and in which situations `AsyncGroupChild::wait` may not behave as expected when cancelled. diff --git a/src/stdlib/erased.rs b/src/stdlib/erased.rs index 76ff229..2ee4d9a 100644 --- a/src/stdlib/erased.rs +++ b/src/stdlib/erased.rs @@ -19,6 +19,17 @@ pub enum ErasedChild { } impl ErasedChild { + /// Returns the OS-assigned process (group) identifier. + /// + /// - Grouped: [`GroupChild::id`] + /// - Ungrouped: [`Child::id`] + pub fn id(&mut self) -> u32 { + match self { + Self::Grouped(c) => c.id(), + Self::Ungrouped(c) => c.id(), + } + } + /// Forces the child to exit. /// /// - Grouped: [`GroupChild::kill`] diff --git a/src/tokio/erased.rs b/src/tokio/erased.rs index baf682c..e96389e 100644 --- a/src/tokio/erased.rs +++ b/src/tokio/erased.rs @@ -20,6 +20,17 @@ pub enum ErasedChild { } impl ErasedChild { + /// Returns the OS-assigned process (group) identifier. + /// + /// - Grouped: [`AsyncGroupChild::id`] + /// - Ungrouped: [`Child::id`] + pub fn id(&mut self) -> Option { + match self { + Self::Grouped(c) => c.id(), + Self::Ungrouped(c) => c.id(), + } + } + /// Forces the child to exit. /// /// - Grouped: [`AsyncGroupChild::kill`]