pub struct Process { /* private fields */ }
Expand description
Implementations§
Source§impl Process
impl Process
Sourcepub fn wait(self) -> Result<ExitStatus>
pub fn wait(self) -> Result<ExitStatus>
Waits for the WSL process to exit completely.
Examples found in repository?
examples/basic.rs (line 32)
5fn main() {
6 let ubuntu = "Ubuntu";
7 let nonexistant = "Nonexistant";
8
9 let wsl = Library::new().unwrap();
10 assert!( wsl.is_distribution_registered(ubuntu));
11 assert!(!wsl.is_distribution_registered(nonexistant));
12 assert!(wsl.get_distribution_configuration(nonexistant).is_err());
13
14 let cfg = wsl.get_distribution_configuration(ubuntu).unwrap();
15 assert!(cfg.default_uid == 0 || (1000 ..= 2000).contains(&cfg.default_uid)); // Root or regular UID
16 assert!(cfg.flags & WSL_DISTRIBUTION_FLAGS::DEFAULT == WSL_DISTRIBUTION_FLAGS::DEFAULT);
17 assert!((1..=2).contains(&cfg.version)); // WSL version
18
19 println!("Environment varibales:");
20 for (k,v) in cfg.default_environment_variables.iter() {
21 // XXX: This might be inaccurate / depend on the linux locale? Good enough for a demo though!
22 let k = String::from_utf8_lossy(k);
23 let v = String::from_utf8_lossy(v);
24 println!("{: <10} = {}", k, v);
25 }
26
27 wsl.launch_interactive(ubuntu, "echo testing 123", true).unwrap();
28
29 let stdin = "echo testing 456\necho PATH: ${PATH}\nasdf";
30 let stdout = std::fs::File::create("target/basic.txt").unwrap();
31 let stderr = std::fs::File::create("CON").unwrap();
32 wsl.launch(ubuntu, "sh", true, stdin, stdout, stderr).unwrap().wait().unwrap();
33
34 println!("\rPress ENTER to quit");
35 let _ = std::io::stdin().read_line(&mut String::new());
36}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Process
impl !RefUnwindSafe for Process
impl !Send for Process
impl !Sync for Process
impl Unpin for Process
impl !UnwindSafe for Process
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more