[erlang-questions] concurrency question

Grzegorz Junka list1@REDACTED
Fri Sep 30 18:18:00 CEST 2016


On 30/09/2016 01:25, Mark Bucciarelli wrote:
> I have a program that does the following:
>
> - start gen_event, naming it "dispatcher"
> - spawn a process
> - send 60 message to process then a stop message
> - exit
>
> The spawned process outputs a line to stdout for
> each message recieved, and after 40 or so messages,
> the spawned process calls gen_event:notify(dispatcher, ...).
>
> This has the obvious bug that when the event is fired, the
> dispatcher is long gone.
>
> When I run this from the command line like this:
>
>     erl -run simulation -run init stop
>
> the spawned process does not print any error message to
> the console when it crashes.
>
> But when I run it from inside the interpreter,
>
>     > simulation:start().
>
> I see:
>
> ** exception error: no such process or port
>
> (which is gen_event saying hey, I can't notify the Pid with that name
>
> because it's gone.)
>
>
> Why don't I get that error output when I run from the console?
>
>

If you spawn the dispatcher from the shell then it will be linked to the 
shell process. So, won't be actually gone.

Grzegorz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160930/e5591228/attachment.htm>


More information about the erlang-questions mailing list