Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

대기

process::Child가 종료될 때까지 기다리려면 Child::wait를 호출해야 하며, 이는 process::ExitStatus를 반환합니다.

use std::process::Command;

fn main() {
    let mut child = Command::new("sleep").arg("5").spawn().unwrap();
    let _result = child.wait().unwrap();

    println!("메인의 끝에 도달함");
}
$ rustc wait.rs && ./wait
# `wait`는 `sleep 5` 명령어가 끝날 때까지 5초 동안 계속 실행됩니다
reached end of main