diff --git a/lib/net/scp.rb b/lib/net/scp.rb index 5b04d98..2cab3c5 100644 --- a/lib/net/scp.rb +++ b/lib/net/scp.rb @@ -376,6 +376,9 @@ def start_command(mode, local, remote, options={}, &callback) end # At this point, :state can be :finish or :next_item send("#{channel[:state]}_state", channel) + ensure + io = channel[:io] + io.close if io && io != channel[:local] && !io.closed? end channel.on_data { |ch2, data| channel[:buffer].append(data) } channel.on_extended_data { |ch2, type, data| debug { data.chomp } }