@@ -495,14 +495,15 @@ def to_cmd_str(cmd):
495
495
else :
496
496
executable , shell = None , False
497
497
498
- stderr = subprocess .PIPE if split_stderr else subprocess .STDOUT
498
+ stderr_handle = subprocess .PIPE if split_stderr else subprocess .STDOUT
499
+ stdin_handle = subprocess .PIPE if stdin or qa_patterns else None
499
500
500
501
log_msg = f"Running { interactive_msg } shell command '{ cmd_str } ' in { work_dir } "
501
502
if thread_id :
502
503
log_msg += f" (via thread with ID { thread_id } )"
503
504
_log .info (log_msg )
504
505
505
- proc = subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = stderr , stdin = subprocess . PIPE ,
506
+ proc = subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = stderr_handle , stdin = stdin_handle ,
506
507
cwd = work_dir , env = env , shell = shell , executable = executable )
507
508
508
509
# 'input' value fed to subprocess.run must be a byte sequence
@@ -515,7 +516,8 @@ def to_cmd_str(cmd):
515
516
# make stdout, stderr, stdin non-blocking files
516
517
channels = [proc .stdout , proc .stdin ]
517
518
if split_stderr :
518
- channels += proc .stderr
519
+ channels .append (proc .stderr )
520
+
519
521
for channel in channels :
520
522
fd = channel .fileno ()
521
523
flags = fcntl .fcntl (fd , fcntl .F_GETFL )
0 commit comments