Calling exit() on that pid seemed to do the trick. Thanks for the help!<br><br>Dave<br><br><br><div class="gmail_quote">On Mon, Dec 8, 2008 at 10:18 PM, Bernard Duggan <span dir="ltr"><<a href="mailto:bernie@m5net.com">bernie@m5net.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Two ways spring to mind.<br>
<br>
The first is to create it as a linked process using spawn_link() rather<br>
than spawn() (or by subsequently calling link()). Then, when the<br>
process that spawned it dies, it will die too. Of course, the reverse<br>
is also true (the spawning process will die if the spawned one exists)<br>
unless it has trap_exit enabled.<br>
<br>
The other is to call exit(SpawnedPid, Reason) where 'Reason' is<br>
something other than 'normal'.<br>
<br>
There's probably other ways too that I can't think of right now (besides<br>
just shutting down the whole vm of course).<br>
<div class="Ih2E3d"><br>
Cheers,<br>
<br>
Bernard<br>
<br>
David Tucker wrote:<br>
</div><div class="Ih2E3d">> Thanks for the info. Is there a clean way to shut down a process that<br>
> is blocking on io:get_line()?<br>
><br>
> Dave<br>
><br>
><br>
> On Mon, Dec 8, 2008 at 10:08 PM, Bernard Duggan <<a href="mailto:bernie@m5net.com">bernie@m5net.com</a><br>
</div><div><div></div><div class="Wj3C7c">> <mailto:<a href="mailto:bernie@m5net.com">bernie@m5net.com</a>>> wrote:<br>
><br>
> While someone else can probably explain exactly why you're getting<br>
> that<br>
> particular message (I could guess, but I'd probably get it wrong),<br>
> I can<br>
> at least tell you why your test isn't working :)<br>
> The use of "-s init stop" tells the erts to execute "init:stop" as<br>
> soon<br>
> as the previous function ("inp:start") returns. The problem you're<br>
> having is that inp:start spawns a thread and returns straight<br>
> away. The<br>
> erts then calls init:stop, killing off the whole elang vm (and,<br>
> presumably, creating some kind of error condition in the remaining<br>
> thread which is the output you're seeing).<br>
> You need to either have inp:start wait until its child process has<br>
> completed (perhaps with a 'receive' block), or not tell the vm to shut<br>
> down using "-s init stop".<br>
><br>
> Hope that's some help.<br>
><br>
> Cheers,<br>
><br>
> Bernard<br>
><br>
> David Tucker wrote:<br>
> > Hi folks,<br>
> ><br>
> > My simple program below gives an error on exit. Any idea what is<br>
> > wrong? Thanks.<br>
> ><br>
> > Dave<br>
> ><br>
> > ---<br>
> ><br>
> > $ cat inp.erl<br>
> > -module(inp).<br>
> > -compile(export_all).<br>
> ><br>
> > start() -><br>
> > spawn(fun() -> one_line() end).<br>
> ><br>
> > one_line() -><br>
> > case io:get_line("") of<br>
> > Str -> lib:nonl(Str)<br>
> > end.<br>
> > $ erlc inp.erl<br>
> > $ erl -noshell -s inp start -s init stop<br>
> > {error_logger,{{2008,12,8},{21,39,50}},"~s~n",["Error in process<br>
> > <0.28.0> with exit value:<br>
> ><br>
> {badarg,[{code_server,call,2},{error_handler,undefined_function,3}]}\n"]}<br>
> > $ port info erlang | head -1<br>
> > erlang R12B-5, lang/erlang (Variants: universal, smp, ssl, hipe,<br>
> i386)<br>
> ><br>
> ><br>
> ------------------------------------------------------------------------<br>
> ><br>
> > _______________________________________________<br>
> > erlang-questions mailing list<br>
</div></div>> > <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a> <mailto:<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br>
<div><div></div><div class="Wj3C7c">> > <a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
><br>
<br>
</div></div></blockquote></div><br>