diff --git a/modules/shell/tests/transcription.rs b/modules/shell/tests/transcription.rs index 3ba3de6d..44641049 100644 --- a/modules/shell/tests/transcription.rs +++ b/modules/shell/tests/transcription.rs @@ -102,7 +102,17 @@ fn a_transcript_ended_by_kitokey_ends_with_what_it_started_and_is_not_written() assert!(alive(&child)); transcription.end(); assert_eq!(end(&said), Made::Failed(String::new())); - assert!(!alive(&child), "what the program started is left running"); + // Its group killed, the child is gone once the KILL is delivered and it is reaped — by the + // system, its parent gone: a moment after the answer on a loaded machine, a zombie meanwhile, + // which `kill -0` still finds (#845). Waited for as a state, within half a second. + let killed = std::time::Instant::now(); + while !gone(&child) && killed.elapsed() < Duration::from_millis(500) { + std::thread::sleep(Duration::from_millis(10)); + } + assert!( + gone(&child), + "what the program started is left running half a second after the answer" + ); assert!(!folder.path().join("session/transcript.jsonl").exists()); } @@ -341,9 +351,16 @@ sleep 60"#, let pressed = std::time::Instant::now(); transcription.cancel(); let ended = said.recv_timeout(Duration::from_secs(2)).expect("not ended within two seconds"); + let answered = pressed.elapsed(); assert!(matches!(ended, Made::Failed(_)), "{ended:?}"); - assert!(gone(&child), "its child, deaf to TERM, still runs"); - assert!(pressed.elapsed() <= Duration::from_secs(2)); + assert!(answered <= Duration::from_secs(2), "{answered:?}"); + // The KILL sent, the child is gone once the kernel has delivered it and the process is reaped: + // a moment after the answer on a loaded machine (#845). Waited for as a state, within half a second. + let killed = std::time::Instant::now(); + while !gone(&child) && killed.elapsed() < Duration::from_millis(500) { + std::thread::sleep(Duration::from_millis(10)); + } + assert!(gone(&child), "its child, deaf to TERM, still runs half a second after the answer"); } #[test]