File: process_issue_7144.rs

package info (click to toggle)
rust-tokio 1.48.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,444 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 671 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#![cfg(feature = "process")]
#![warn(rust_2018_idioms)]
#![cfg(target_os = "linux")]
#![cfg(not(miri))]

use tokio::process::Command;
use tokio::time::{sleep, Duration};

#[tokio::test]
async fn issue_7144() {
    let mut threads = vec![];
    for _ in 0..20 {
        threads.push(tokio::spawn(test_one()));
    }
    for thread in threads {
        thread.await.unwrap();
    }
}

async fn test_one() {
    let mut t = Command::new("strace")
        .args("-o /dev/null -D sleep 5".split(' '))
        .spawn()
        .unwrap();
    sleep(Duration::from_millis(100)).await;
    unsafe { libc::kill(t.id().unwrap() as _, libc::SIGINT) };
    t.wait().await.unwrap();
}