[erlang-questions] Problem with io monitor - a bug?

Álvaro avalormaquedano@REDACTED
Fri Nov 30 14:03:34 CET 2012


SMALL UPDATE:


If I "put the shell process to sleep":

> timer:sleep(5000).

The prompt from the io:read appears.
It seems that the shell process "greedily" locks the io monitor...





2012/11/30 Álvaro <avalormaquedano@REDACTED>

> Dear all,
>
> Every time I run this simple code, my program gets stuck:
>
> > Pid = spawn (moduleName,myread,["hello"]).
>
> where:
>
> myread(Prompt)->
>     try
>       Result = io:read(Prompt),
>       io:format("Res: ~p~n",[Result]),
>     catch
>     A:B->
>         io:format("Read error: ~p:~p~n",[A,B]),
>         false
>     end.
>
>
> if I check the status of the process:
>
> > erlang:process_info(Pid).
>
> [{current_function,{io,wait_io_mon_reply,2}},
>  {initial_call,{default_environment,myread,1}},
>  {status,waiting},
>  {message_queue_len,0},
>  {messages,[]},
>  {links,[]},
>  {dictionary,[]},
>  {trap_exit,false},
>  {error_handler,error_handler},
>  {priority,normal},
>  {group_leader,<0.25.0>},
>  {total_heap_size,233},
>  {heap_size,233},
>  {stack_size,7},
>  {reductions,28},
>  {garbage_collection,[{min_bin_vheap_size,46368},
>                       {min_heap_size,233},
>                       {fullsweep_after,65535},
>                       {minor_gcs,0}]},
>  {suspending,[]}]
>
>
> It seems to be stuck in the function io:wait_io_mon_reply/2 (surfing
> through io.erl I found that this function waits for a response from the
> process managing the io ). This process is not answering, hence my code
> stops working.
> I've checked that the "group_leader()" once I spawn the reading process is
> the same used by my shell.
>
> Any ideas on how to deal with it?
>
> Regards,
> Álvaro
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121130/8bb46570/attachment.htm>


More information about the erlang-questions mailing list