[erlang-questions] can flush the shell but can't receive from it

arif <>
Mon Nov 17 22:38:06 CET 2014


I have the simplest of applications that consists of just the skeleton 
gen_server, registered locally as "server", with one callback 

   handle_info({From, A, B}, State) ->
     From ! {self(), A + B},
     {noreply, State};

i.e. a simple adder

The supervisor is the skeleton one_for_one supervisor. The application, 
app, the skeleton application.

Here is what I do:

7> application:start(app).
8> server ! {self(), 1, 2}.
9> receive X -> X end.
10> server ! {self(), a, b}.

=ERROR REPORT==== 17-Nov-2014::22:18:42 ===
** Generic server server terminating
** Last message in was {<0.32.0>,a,b}
** When Server state == {state}
** Reason for termination ==
** {badarith,[{server,handle_info,2,[{file,"server.erl"},{line,98}]},
11> server ! {self(), 3, 4}.
12> receive X -> X end.

and here the shell blocks.
The message ({<0.67.0>,7}) is in the shell's mailbox alright. I can see 
it by running observer.

If, instead of receive X -> X end, I do a flush(), the message _is_ 

It is reproducible on R 17, R15B01, on linux and on windows.

What am I doing wrong?

Thanks and best regards

More information about the erlang-questions mailing list