diff options
author | yuzu <yuzu@b9215c17-b818-4693-b096-d1e41a411fef> | 2025-05-29 06:17:28 +0000 |
---|---|---|
committer | yuzu <yuzu@b9215c17-b818-4693-b096-d1e41a411fef> | 2025-05-29 06:17:28 +0000 |
commit | 4d3d9e0805bc5e252e2e44db1f6d67b72c5c7d76 (patch) | |
tree | c224faaa75599aeb8f732ad1fb04e4cd9a570598 | |
parent | d6135c7d89697ab7e514fdd906eda6eb2dc08fc8 (diff) | |
download | salaryman-4d3d9e0805bc5e252e2e44db1f6d67b72c5c7d76.tar.gz salaryman-4d3d9e0805bc5e252e2e44db1f6d67b72c5c7d76.tar.bz2 salaryman-4d3d9e0805bc5e252e2e44db1f6d67b72c5c7d76.zip |
proof of concept: works
git-svn-id: svn+ssh://diminuette.aengel.lesbianunix.dev/salaryman/trunk@2 b9215c17-b818-4693-b096-d1e41a411fef
-rw-r--r-- | Cargo.lock | 7 | ||||
-rw-r--r-- | src/main.rs | 18 |
2 files changed, 23 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a779727 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "salaryman" +version = "0.1.0" diff --git a/src/main.rs b/src/main.rs index e7a11a9..c4ed431 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,17 @@ -fn main() { - println!("Hello, world!"); +use std::process::{Command, Stdio, Child}; +use std::io::Read; + +fn exec(image: &str, args: Vec<&str>) -> Result<Child, Box<dyn std::error::Error>> { + let child = Command::new(image).args(args).stdin(Stdio::piped()).stdout(Stdio::piped()).spawn()?; + Ok(child) +} + +fn main() -> Result<(), Box<dyn std::error::Error>> { + let mut child = exec("java", vec!["-jar", "minecraft_server.jar"])?; + std::thread::sleep(std::time::Duration::from_secs(60)); + let mut buf: [u8; 512] = [0; 512]; + child.stdout.as_mut().unwrap().read(&mut buf[..])?; + println!("{}", String::from_utf8_lossy(&buf)); + child.kill()?; + Ok(()) } |