|
1 | 1 | // examples/git_clone_kernel.rs |
2 | | -#[cfg(unix)] |
3 | | -use std::os::unix::process::ExitStatusExt; |
4 | | -#[cfg(windows)] |
5 | | -use std::os::windows::process::ExitStatusExt; |
| 2 | + |
6 | 3 | use command_timeout::{run_command_with_timeout, CommandError, CommandOutput}; |
| 4 | +use std::os::unix::process::ExitStatusExt; |
7 | 5 | use std::path::PathBuf; // <<< Import PathBuf |
8 | 6 | use std::process::{Command, ExitStatus}; |
9 | 7 | use std::time::Duration; |
@@ -36,11 +34,11 @@ async fn main() -> Result<(), anyhow::Error> { |
36 | 34 | let min_timeout = Duration::from_secs(10); |
37 | 35 | let max_timeout = Duration::from_secs(60 * 60 * 24 * 7); // 1 week (effectively infinite) |
38 | 36 | let activity_timeout = Duration::from_secs(60 * 5); // 5 minutes |
39 | | - // ----------------------------- |
| 37 | + // ----------------------------- |
40 | 38 |
|
41 | 39 | // Create a temporary directory builder |
42 | 40 | let temp_dir_builder = Builder::new().prefix("kernel_clone_persistent").tempdir()?; // Use a different prefix |
43 | | - // --- CHANGE: Keep the path instead of the TempDir object --- |
| 41 | + // --- CHANGE: Keep the path instead of the TempDir object --- |
44 | 42 | let clone_target_path_buf: PathBuf = temp_dir_builder.into_path(); |
45 | 43 | // --- END CHANGE --- |
46 | 44 | let clone_target_path_str = clone_target_path_buf.to_str().unwrap_or("."); // Use "." as fallback if path invalid unicode |
@@ -124,14 +122,9 @@ fn handle_command_output(output: CommandOutput) { |
124 | 122 | warn!("Exit Code: {}", code); |
125 | 123 | } |
126 | 124 | // signal() is now available because ExitStatusExt is in scope |
127 | | - #[cfg(unix)] |
128 | 125 | if let Some(signal) = status.signal() { |
129 | 126 | warn!("Terminated by Signal: {}", signal); |
130 | 127 | } |
131 | | - #[cfg(windows)] |
132 | | - if let Some(code) = status.code() { |
133 | | - warn!("Exit Code: {}", code); |
134 | | - } |
135 | 128 | } |
136 | 129 | } else { |
137 | 130 | warn!("Exit Status: None (Killed by timeout, status unavailable?)"); |
|
0 commit comments