Skip to content

Commit a5e0937

Browse files
committed
do not attach PIPE file handle on STDIN of run_shell_cmd unless there are contents to be passed through it
1 parent 2281945 commit a5e0937

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

easybuild/tools/run.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,15 @@ def to_cmd_str(cmd):
495495
else:
496496
executable, shell = None, False
497497

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
499500

500501
log_msg = f"Running {interactive_msg}shell command '{cmd_str}' in {work_dir}"
501502
if thread_id:
502503
log_msg += f" (via thread with ID {thread_id})"
503504
_log.info(log_msg)
504505

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,
506507
cwd=work_dir, env=env, shell=shell, executable=executable)
507508

508509
# 'input' value fed to subprocess.run must be a byte sequence
@@ -515,7 +516,8 @@ def to_cmd_str(cmd):
515516
# make stdout, stderr, stdin non-blocking files
516517
channels = [proc.stdout, proc.stdin]
517518
if split_stderr:
518-
channels += proc.stderr
519+
channels.append(proc.stderr)
520+
519521
for channel in channels:
520522
fd = channel.fileno()
521523
flags = fcntl.fcntl(fd, fcntl.F_GETFL)

0 commit comments

Comments
 (0)