diff --git a/lib/bolt/shell/bash.rb b/lib/bolt/shell/bash.rb index 631714570..5c533b0b9 100644 --- a/lib/bolt/shell/bash.rb +++ b/lib/bolt/shell/bash.rb @@ -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 @@ -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