File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
library/std/src/sys/pal/windows Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -341,12 +341,21 @@ impl Command {
341341
342342 let mut si = zeroed_startupinfo ( ) ;
343343
344+ // if STARTF_USESTDHANDLES is not used with PSEUDOCONSOLE,
345+ // it is not guaranteed that all the desired stdio of the new process are
346+ // really connected to the new console.
347+ // The problem + solution is described here:
348+ // https://github.com/microsoft/terminal/issues/4380#issuecomment-580865346
349+ const PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE : usize = 0x20016 ;
350+ let force_use_std_handles =
351+ self . proc_thread_attributes . contains_key ( & PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE ) ;
352+
344353 // If at least one of stdin, stdout or stderr are set (i.e. are non null)
345354 // then set the `hStd` fields in `STARTUPINFO`.
346355 // Otherwise skip this and allow the OS to apply its default behaviour.
347356 // This provides more consistent behaviour between Win7 and Win8+.
348357 let is_set = |stdio : & Handle | !stdio. as_raw_handle ( ) . is_null ( ) ;
349- if is_set ( & stderr) || is_set ( & stdout) || is_set ( & stdin) {
358+ if force_use_std_handles || is_set ( & stderr) || is_set ( & stdout) || is_set ( & stdin) {
350359 si. dwFlags |= c:: STARTF_USESTDHANDLES ;
351360 si. hStdInput = stdin. as_raw_handle ( ) ;
352361 si. hStdOutput = stdout. as_raw_handle ( ) ;
You can’t perform that action at this time.
0 commit comments