Skip to content

Commit

Permalink
Merge pull request #3328 from seanmil/close_fds
Browse files Browse the repository at this point in the history
Ensure bash shell executions close file descriptors
  • Loading branch information
donoghuc authored Jun 26, 2024
2 parents 42ec31c + 4005f73 commit a744d03
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit a744d03

Please sign in to comment.