<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 30/09/2016 01:25, Mark Bucciarelli
wrote:<br>
</div>
<blockquote
cite="mid:CAFqAhKptQDxYL7Q-4z6qfmLEnOzp-X-Smbrf=XPke52VxLTY4g@mail.gmail.com"
type="cite">
<div dir="ltr">I have a program that does the following:
<div><br>
</div>
<div>- start gen_event, naming it "dispatcher"</div>
<div>- spawn a process</div>
<div>- send 60 message to process then a stop message</div>
<div>- exit</div>
<div><br>
</div>
<div>The spawned process outputs a line to stdout for</div>
<div>each message recieved, and after 40 or so messages,</div>
<div>the spawned process calls gen_event:notify(dispatcher,
...).<br>
</div>
<div><br>
</div>
<div>This has the obvious bug that when the event is fired, the</div>
<div>dispatcher is long gone.</div>
<div><br>
</div>
<div>When I run this from the command line like this:</div>
<div><br>
</div>
<div> erl -run simulation -run init stop<br clear="all">
<div><br>
</div>
<div>the spawned process does not print any error message to</div>
<div>the console when it crashes.</div>
<div><br>
</div>
<div>But when I run it from inside the interpreter, </div>
<div><br>
</div>
<div> > simulation:start().</div>
<div><br>
</div>
<div>I see:</div>
<div>
<p class="gmail-p1">** exception error: no such process or
port</p>
<p class="gmail-p1">(which is gen_event saying hey, I can't
notify the Pid with that name</p>
<p class="gmail-p1">because it's gone.)</p>
<p class="gmail-p1"><br>
</p>
<p class="gmail-p1">Why don't I get that error output when I
run from the console?</p>
<br>
</div>
</div>
</div>
</blockquote>
<br>
If you spawn the dispatcher from the shell then it will be linked to
the shell process. So, won't be actually gone.<br>
<br>
Grzegorz<br>
</body>
</html>