Skip to content

Commit 52dccd8

Browse files
fix(procmgr): fall back to inherit when Windows stdio file redirect fails
Warn and reuse the inherit/NUL stdio path when CreateFileW cannot open a configured stdout/stderr file, matching Unix and tokio spawn behavior.
1 parent f2e490f commit 52dccd8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • pkg/procmgr/rust/src/platform/windows/spawn

pkg/procmgr/rust/src/platform/windows/spawn/stdio.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,19 @@ mod tests {
287287
let contents = std::fs::read_to_string(&path).unwrap();
288288
assert!(contents.contains("fileline"), "got {contents:?}");
289289
}
290+
291+
#[test]
292+
fn unopenable_file_path_falls_back_to_inherit() {
293+
let bad_path = StdioSetting::File(PathBuf::from(
294+
r"C:\nonexistent_pmgr_stdio_dir\out.log",
295+
));
296+
let handle = map_stdio_setting(
297+
"test-proc",
298+
&bad_path,
299+
STD_OUTPUT_HANDLE,
300+
&AgentAccount::LocalSystem,
301+
)
302+
.expect("map_stdio_setting should fall back instead of failing spawn");
303+
assert!(!handle.raw().is_null());
304+
}
290305
}

0 commit comments

Comments
 (0)