[erlang-questions] {badarg, [{code_server, call, 2}, {error_handler, undefined_function, 3}]}

David Tucker dbtleonia@REDACTED
Tue Dec 9 07:27:23 CET 2008


Calling exit() on that pid seemed to do the trick.  Thanks for the help!

Dave


On Mon, Dec 8, 2008 at 10:18 PM, Bernard Duggan <bernie@REDACTED> wrote:

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


More information about the erlang-questions mailing list