From 6e8c2bd2b3cd0edc6a5194ba575f6ee57e2f3a37 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 19 Apr 2026 22:27:55 +0200 Subject: [PATCH] test_infra: Test multiple spawns share one process group Spawn two processes under the same test name and verify they have the same group PID. Cleanup kills both. Signed-off-by: Anatol Belski --- test_infra/src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index 7b2cafb42..1ce436ba1 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -2626,4 +2626,30 @@ mod unit_tests { let _ = child.wait(); assert!(!is_alive(pid)); } + + #[test] + fn process_registry_shared_group() { + let name = "test_shared_group"; + + let mut cmd1 = Command::new("sleep"); + cmd1.arg("60"); + let mut child1 = ProcessRegistry::spawn(name, &mut cmd1).unwrap(); + let pid1 = child1.id(); + + let mut cmd2 = Command::new("sleep"); + cmd2.arg("60"); + let mut child2 = ProcessRegistry::spawn(name, &mut cmd2).unwrap(); + let pid2 = child2.id(); + + let pgid1 = unsafe { libc::getpgid(pid1 as i32) }; + let pgid2 = unsafe { libc::getpgid(pid2 as i32) }; + assert_eq!(pgid1, pgid2); + assert_eq!(pgid1, pid1 as i32); + + assert!(ProcessRegistry::cleanup(name)); + let _ = child1.wait(); + let _ = child2.wait(); + assert!(!is_alive(pid1)); + assert!(!is_alive(pid2)); + } }