Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not attach PIPE file handle on STDIN of run_shell_cmd unless there are contents for it #4728

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions easybuild/tools/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,15 @@ def to_cmd_str(cmd):
else:
executable, shell = None, False

stderr = subprocess.PIPE if split_stderr else subprocess.STDOUT
stderr_handle = subprocess.PIPE if split_stderr else subprocess.STDOUT
stdin_handle = subprocess.PIPE if stdin or qa_patterns else None

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

proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=stderr, stdin=subprocess.PIPE,
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=stderr_handle, stdin=stdin_handle,
cwd=work_dir, env=env, shell=shell, executable=executable)

# 'input' value fed to subprocess.run must be a byte sequence
Expand All @@ -515,7 +516,8 @@ def to_cmd_str(cmd):
# make stdout, stderr, stdin non-blocking files
channels = [proc.stdout, proc.stdin]
if split_stderr:
channels += proc.stderr
channels.append(proc.stderr)

for channel in channels:
fd = channel.fileno()
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
Expand Down
Loading