aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src
diff options
context:
space:
mode:
authorSvilen Ivanov <[email protected]>2016-09-19 15:59:21 +0300
committerSvilen Ivanov <[email protected]>2016-09-19 15:59:21 +0300
commit5e698cb679546dae32c64fabd4e5a65cb5886297 (patch)
tree8b67916f13417b4746c77d52179f1cff51a26aec /lib/ssh/src
parent27d3d5c6f6ddd51dc27d684b613c8c261f19a82f (diff)
downloadotp-5e698cb679546dae32c64fabd4e5a65cb5886297.tar.gz
otp-5e698cb679546dae32c64fabd4e5a65cb5886297.tar.bz2
otp-5e698cb679546dae32c64fabd4e5a65cb5886297.zip
Fix SSH custom REPL exit status
When user defined SSH shell REPL process exits with reason normal SSH channel callback module should report successful exit status to the SSH client. This provides simple way for SSH clients to check for successful completion of executed commands.
Diffstat (limited to 'lib/ssh/src')
-rw-r--r--lib/ssh/src/ssh_cli.erl11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl
index 74cd2e081a..8af0ecc5f9 100644
--- a/lib/ssh/src/ssh_cli.erl
+++ b/lib/ssh/src/ssh_cli.erl
@@ -208,8 +208,15 @@ handle_msg({Group, Req}, #state{group = Group, buf = Buf, pty = Pty,
write_chars(ConnectionHandler, ChannelId, Chars),
{ok, State#state{buf = NewBuf}};
-handle_msg({'EXIT', Group, _Reason}, #state{group = Group,
- channel = ChannelId} = State) ->
+handle_msg({'EXIT', Group, Reason}, #state{group = Group,
+ cm = ConnectionHandler,
+ channel = ChannelId} = State) ->
+ Status = case Reason of
+ normal -> 0;
+ _ -> -1
+ end,
+ ssh_connection:exit_status(ConnectionHandler, ChannelId, Status),
+ ssh_connection:send_eof(ConnectionHandler, ChannelId),
{stop, ChannelId, State};
handle_msg(_, State) ->