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

Ensure bash shell executions close file descriptors #3328

Merged
merged 1 commit into from
Jun 26, 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
5 changes: 4 additions & 1 deletion lib/bolt/shell/bash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ def execute(command, sudoable: false, **options)
result_output.merged_output << to_print
}
rescue Errno::EAGAIN, EOFError
ensure
stream.close
end
inp.close
result_output.stdout << read_streams[out]
result_output.stderr << read_streams[err]
result_output.exit_code = t.value.respond_to?(:exitstatus) ? t.value.exitstatus : t.value
Expand All @@ -490,7 +493,7 @@ def execute(command, sudoable: false, **options)
result_output
rescue StandardError
# Ensure we close stdin and kill the child process
inp&.close
inp.close unless inp.nil? || inp.closed?
t&.terminate if t&.alive?
@logger.trace { "Command aborted" }
raise
Expand Down
Loading