blob: f376c15475d10d7e249247f917be2fe0b145c8c1 [file] [log] [blame]
#![cfg(all(unix, feature = "process"))]
use std::process::Stdio;
use std::time::Duration;
use tokio::io::AsyncReadExt;
use tokio::process::Command;
use tokio::time::delay_for;
use tokio_test::assert_ok;
async fn kill_on_drop() {
let mut cmd = Command::new("sh");
# Fork another child that won't get killed
sh -c 'sleep 1; echo child ran' &
disown -a
# Await our death
sleep 5
echo hello from beyond the grave
let mut child = cmd
let mut out = child.stdout.take().unwrap();
let mut msg = String::new();
assert_ok!(out.read_to_string(&mut msg).await);
assert_eq!("child ran\n", msg);