aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/kernel/doc/src/heart.xml9
-rw-r--r--lib/kernel/src/heart.erl20
2 files changed, 19 insertions, 10 deletions
diff --git a/lib/kernel/doc/src/heart.xml b/lib/kernel/doc/src/heart.xml
index f5028a5559..3ec33d2f18 100644
--- a/lib/kernel/doc/src/heart.xml
+++ b/lib/kernel/doc/src/heart.xml
@@ -118,8 +118,13 @@
the system. The new Erlang runtime system will (if it
misbehaves) use the environment variable
<c>HEART_COMMAND</c> to reboot.</p>
- <p>Limitations: The length of the <c><anno>Cmd</anno></c> command string
- must be less than 2047 characters.</p>
+
+ <p>Limitations: The <c><anno>Cmd</anno></c> command string
+ will be sent to the heart program as a ISO-latin-1 or UTF-8
+ encoded binary depending on the file name encoding mode of the
+ emulator (see
+ <seealso marker="kernel:file#native_name_encoding/0"><c>file:native_name_encoding/0</c></seealso>).
+ The size of the encoded binary must be less than 2047 bytes.</p>
</desc>
</func>
<func>
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, ""),