diff options
author | Stefan Zegenhagen <stefan.zegenhagen@arcutronix.com> | 2013-05-06 14:33:46 +0200 |
---|---|---|
committer | Fredrik Gustafsson <fredrik@erlang.org> | 2013-05-06 15:03:55 +0200 |
commit | 59053f84228b27ecf28f2de31b4a45074b2d04c9 (patch) | |
tree | 9dc50939d795b175f2576c95f9529c2f1c666eef /lib/ssh/src/ssh_cli.erl | |
parent | d08b9775ad07a89d070aa653a1e5549ce705d524 (diff) | |
download | otp-59053f84228b27ecf28f2de31b4a45074b2d04c9.tar.gz otp-59053f84228b27ecf28f2de31b4a45074b2d04c9.tar.bz2 otp-59053f84228b27ecf28f2de31b4a45074b2d04c9.zip |
Make ssh_cli.erl handle <CTRL>+C
Dear all,
I've found that ssh_cli.erl does not scan the input received from the
remote for occurrences of <CTRL>+C to signal the user's interrupt
requests to the group_leader of the CLI session. The patch attached to
this e-mail fixes the issue.
Kind regards,
--
Dr. Stefan Zegenhagen
arcutronix GmbH
Garbsener Landstr. 10
30419 Hannover
Germany
Tel: +49 511 277-2734
Fax: +49 511 277-2709
Email: stefan.zegenhagen@arcutronix.com
Web: www.arcutronix.com
*Synchronize the Ethernet*
General Managers: Dipl. Ing. Juergen Schroeder, Dr. Josef Gfrerer -
Legal Form: GmbH, Registered office: Hannover, HRB 202442, Amtsgericht
Hannover; Ust-Id: DE257551767.
Please consider the environment before printing this message.
>From f1d056ed1bf419677098cdc57bc7ce8a327e6b43 Mon Sep 17 00:00:00 2001
From: Stefan Zegenhagen <stefan.zegenhagen@arcutronix.com>
Date: Mon, 6 May 2013 14:29:45 +0200
Subject: [PATCH] [SSH-CLI] properly handle <CTRL>+C as shell interrupt
In ssh_cli.erl, check for the presence of <CTRL>+C in data received from
the remote. If detected, use the established mechanism (send an
'interrupt' exit signal to the group_leader) to signal an interrupt to
the shell.
Diffstat (limited to 'lib/ssh/src/ssh_cli.erl')
-rw-r--r-- | lib/ssh/src/ssh_cli.erl | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl index 69b1ab186f..54911e757c 100644 --- a/lib/ssh/src/ssh_cli.erl +++ b/lib/ssh/src/ssh_cli.erl @@ -68,7 +68,8 @@ init([Shell]) -> handle_ssh_msg({ssh_cm, _ConnectionManager, {data, _ChannelId, _Type, Data}}, #state{group = Group} = State) -> - Group ! {self(), {data, binary_to_list(Data)}}, + List = binary_to_list(Data), + to_group(List, Group), {ok, State}; handle_ssh_msg({ssh_cm, ConnectionManager, @@ -188,6 +189,22 @@ terminate(_Reason, _State) -> %%% Internal functions %%-------------------------------------------------------------------- +to_group([], _Group) -> + ok; +to_group([$\^C | Tail], Group) -> + exit(Group, interrupt), + to_group(Tail, Group); +to_group(Data, Group) -> + Func = fun(C) -> C /= $\^C end, + Tail = case lists:splitwith(Func, Data) of + {[], Right} -> + Right; + {Left, Right} -> + Group ! {self(), {data, Left}}, + Right + end, + to_group(Tail, Group). + exec(Cmd) -> case eval(parse(scan(Cmd))) of {error, _} -> |