aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/heart.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-06-05 14:56:28 +0200
committerSiri Hansen <[email protected]>2013-06-05 14:56:28 +0200
commit00e93e8948c84bc5150e3c8dbea0820e60491461 (patch)
tree638746f90af23c845598becfa0029bd374a5de88 /lib/kernel/src/heart.erl
parent23623a4837f3971623549c73257474d828fe25f2 (diff)
parentd632c13e6f8953855284f3c2317e94a1e69fa2f5 (diff)
downloadotp-00e93e8948c84bc5150e3c8dbea0820e60491461.tar.gz
otp-00e93e8948c84bc5150e3c8dbea0820e60491461.tar.bz2
otp-00e93e8948c84bc5150e3c8dbea0820e60491461.zip
Merge branch 'siri/kernel/heart-set_cmd-unicode/OTP-10843'
* siri/kernel/heart-set_cmd-unicode/OTP-10843: Convert command string to encoded binary in heart:set_cmd/1 Conflicts: lib/kernel/src/heart.erl
Diffstat (limited to 'lib/kernel/src/heart.erl')
-rw-r--r--lib/kernel/src/heart.erl20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/kernel/src/heart.erl b/lib/kernel/src/heart.erl
index aa65c3a474..daed6dd488 100644
--- a/lib/kernel/src/heart.erl
+++ b/lib/kernel/src/heart.erl
@@ -184,14 +184,18 @@ wait_ack(Port) ->
loop(Parent, Port, Cmd) ->
_ = send_heart_beat(Port),
receive
- {From, set_cmd, NewCmd} when length(NewCmd) < 2047 ->
- _ = send_heart_cmd(Port, NewCmd),
- _ = wait_ack(Port),
- From ! {heart, ok},
- loop(Parent, Port, NewCmd);
- {From, set_cmd, NewCmd} ->
- From ! {heart, {error, {bad_cmd, NewCmd}}},
- loop(Parent, Port, Cmd);
+ {From, set_cmd, NewCmd0} ->
+ Enc = file:native_name_encoding(),
+ case catch unicode:characters_to_binary(NewCmd0,Enc,Enc) of
+ NewCmd when is_binary(NewCmd), byte_size(NewCmd) < 2047 ->
+ _ = send_heart_cmd(Port, NewCmd),
+ _ = wait_ack(Port),
+ From ! {heart, ok},
+ loop(Parent, Port, NewCmd);
+ _ ->
+ From ! {heart, {error, {bad_cmd, NewCmd0}}},
+ loop(Parent, Port, Cmd)
+ end;
{From, clear_cmd} ->
From ! {heart, ok},
_ = send_heart_cmd(Port, ""),