Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Raise an error if the shell does not exit successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
carllerche committed Feb 11, 2011
1 parent 8663391 commit 0566789
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/net/ssh/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def open(&callback)
@state = :opening
@channel = session.open_channel(&method(:open_succeeded))
@channel.on_open_failed(&method(:open_failed))
@channel.on_request('exit-status', &method(:on_exit_status))
end
when_open(&callback) if callback
self
Expand Down Expand Up @@ -143,6 +144,12 @@ def open_failed(channel, code, description)
raise "could not open channel for process manager (#{description}, ##{code})"
end

def on_exit_status(channel, data)
unless data.read_long == 0
raise "the shell exited unexpectedly"
end
end

def pty_requested(channel, success)
@state = :shell
raise "could not request pty for process manager" unless success
Expand Down

0 comments on commit 0566789

Please sign in to comment.