SHARE
TWEET

Untitled

a guest Aug 18th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unused)]
  2. use std::io::{BufRead, BufReader};
  3. use std::process;
  4.  
  5. fn main() {
  6.     let mut child = process::Command::new("yes")
  7.         .stdout(process::Stdio::piped())
  8.         .spawn()
  9.         .expect("Failed to exec");
  10.    
  11.     // ここでstdoutを何行かprintして
  12.     let buf = BufReader::new(child.stdout.as_mut().unwrap());
  13.     buf.lines().take(10).for_each(|l| {println!("{:?}", l.unwrap())});
  14.    
  15.     // killしたい
  16.     child.kill().unwrap();
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top