aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-02-13 19:47:27 +0100
committerSiri Hansen <[email protected]>2013-03-19 14:50:12 +0100
commitd632c13e6f8953855284f3c2317e94a1e69fa2f5 (patch)
tree95746e8f9a960a501b7811cf901d6e797b588d6f /lib/kernel/src
parent0be34905e603ca9e1acb5ea763bf25cdab8d5d7c (diff)
downloadotp-d632c13e6f8953855284f3c2317e94a1e69fa2f5.tar.gz
otp-d632c13e6f8953855284f3c2317e94a1e69fa2f5.tar.bz2
otp-d632c13e6f8953855284f3c2317e94a1e69fa2f5.zip
Convert command string to encoded binary in heart:set_cmd/1
OTP-10843 In order to allow unicode filenames in heart commands, the command string is now encoded according to the file name translation mode of the emulator (file:native_name_encoding()) before it is sent to the heart process.
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/heart.erl22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/kernel/src/heart.erl b/lib/kernel/src/heart.erl
index 87cb9d7f51..a3790e90cf 100644
--- a/lib/kernel/src/heart.erl
+++ b/lib/kernel/src/heart.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -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, ""),