Skip to content

Commit c4c4640

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 ce5471c commit c4c4640

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
@@ -289,4 +289,19 @@ mod tests {
289289
let contents = std::fs::read_to_string(&path).unwrap();
290290
assert!(contents.contains("fileline"), "got {contents:?}");
291291
}
292+
293+
#[test]
294+
fn unopenable_file_path_falls_back_to_inherit() {
295+
let bad_path = StdioSetting::File(PathBuf::from(
296+
r"C:\nonexistent_pmgr_stdio_dir\out.log",
297+
));
298+
let handle = map_stdio_setting(
299+
"test-proc",
300+
&bad_path,
301+
STD_OUTPUT_HANDLE,
302+
&AgentAccount::LocalSystem,
303+
)
304+
.expect("map_stdio_setting should fall back instead of failing spawn");
305+
assert!(!handle.raw().is_null());
306+
}
292307
}

0 commit comments

Comments
 (0)