diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kernel/doc/src/heart.xml | 9 | ||||
-rw-r--r-- | lib/kernel/src/heart.erl | 20 |
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, ""), |