Changes to group leader with introduction of unicode features

Eric Merritt cyberlync@REDACTED
Fri Jul 10 03:43:46 CEST 2009


Guys,

 I am trying to debug a problem in my code. I have a group leader that
'captures' io from a couple of Erlang libraries that expect to
communicate directly with the user. It seems that the introduction of
unicode changed the implementation of group leaders in some obvious
and non-obvious ways. The obvious ways where pretty strait forward to
cover. However, I am having a bit of trouble with the non-obvious
problems.

 I have a gen server that acts as a group leader.  It receives IO
messages in its handle_info the exiting code looks as follows. Somehow
 I am garbling the io message. I am consistently getting the following
error.  The no_translation message seems to be coming from deep in the
io layer.  I suspect that I am missing something obvious but I could
use a pointer to the right direction.

doc:io generated event:error in doclet 'edoc_doclet':
{'EXIT',{no_translation,[{io,put_chars,[<0.724.0>,unicode,[[60,33,68,79,67,84,89|...],[45,47,47,87,51,67|...],[34],[],[62,10],[[[...]|...],[...]]]]},{edoc_lib,write_file,4},{edoc_doclet,gen,6},{edoc_lib,run_plugin,5},{dbg_debugged,reply,1},{dbg_debugged,handle_command,2},{dbg_debugged,msg_loop,3},{eta_task_runner,apply_task,3}]}}.


.
handle_info({io_request, From, ReplyAs,
             {put_chars, io_lib, Func, [Format, Args]}},
            State) when is_list(Format) ->
    Msg = (catch io_lib:Func(Format,Args)),
    handle_msg(ReplyAs, Msg, From, Func, State),
    {noreply, State};
handle_info({io_request, From, ReplyAs,
             {put_chars, unicode, io_lib, Func, [Format, Args]}},
            State) when is_list(Format) ->
    Msg = (catch io_lib:Func(Format,Args)),
    handle_msg(ReplyAs, Msg, From, Func, State),
    {noreply, State};
handle_info({io_request, From, ReplyAs,
             {put_chars, io_lib, Func, [Format, Args]}}, State)
  when is_atom(Format) ->
    Msg = (catch io_lib:Func(Format,Args)),
    handle_msg(ReplyAs, Msg, From, Func, State),
    {noreply, State};
handle_info({io_request, From, ReplyAs,
             {put_chars, unicode, io_lib, Func, [Format, Args]}}, State)
  when is_atom(Format) ->
    Msg = (catch io_lib:Func(Format,Args)),
    handle_msg(ReplyAs, Msg, From, Func, State),
    {noreply, State};
handle_info({io_request, From, ReplyAs, {put_chars, Bytes}}, State) ->
    handle_msg(ReplyAs, Bytes, From, put_chars, State),
    {noreply, State};
handle_info({io_request, From, ReplyAs, {put_chars,unicode,Bytes}}, State) ->
    handle_msg(ReplyAs, Bytes, From, put_chars, State),
    {noreply, State};
handle_info(IoReq, State) when element(1, IoReq) == io_request ->
    %% something else, just pass it on
    group_leader() ! IoReq,
    {noreply, State};
handle_info(_, State) ->
    {noreply, State}.

handle_msg(ReplyAs, Msg, From, Func,
           #state{build_id=BuildId, task=Task, type=Type}) ->
    case Msg of
	{'EXIT',_} ->
	    From ! {io_reply,ReplyAs,{error,Func}};
	_ ->
	    From ! {io_reply,ReplyAs,ok}
    end,
    eta_event:task_event(BuildId, Task, Type, Msg).


More information about the erlang-questions mailing list