Basic "What am I doing wrong?" question (Tuple argument to spawn? Dead pid intead of a runtime error?)
Luke Gorrie
luke@REDACTED
Fri Feb 14 19:17:43 CET 2003
"Jonathan Coupe" <jonathan@REDACTED> writes:
> Yeah, it's your basic idiotic syntax error. (Doh.) The tip about module is
> nice. What I still don't understand is why I didn't get a runtime error..?
You did, but it occured in the new process, and since it wasn't linked
with anything its crash went unreported.
Links are helpful here. For example:
1> spawn(nosuchmodule, foo, []).
<0.29.0>
2> spawn_link(nosuchmodule, foo, []).
<0.31.0>
** exited: {undef,[{nosuchmodule,foo,[]}]} **
There is also much more detailed error logging available via the OTP
libraries, if you start the SASL application:
3> application:start(sasl).
Then you can use proc_lib:spawn, which is just like 'spawn' except
that it will log an error if the process crashes:
4> proc_lib:spawn(nosuchmodule, foo, []).
<0.53.0>
5>
=CRASH REPORT==== 14-Feb-2003::19:08:35 ===
crasher:
pid: <0.53.0>
registered_name: []
error_info: {undef,[{nosuchmodule,foo,[]},{proc_lib,init_p,5}]}
initial_call: {nosuchmodule,foo,[]}
ancestors: [<0.33.0>]
messages: []
links: []
dictionary: []
trap_exit: false
status: running
heap_size: 233
stack_size: 23
reductions: 83
neighbours:
Note that you don't need a link in this case, since proc_lib's spawn
function will always send a message to SASL's error logger if the
process crashes.
(NB: SASL stands for System Architecture Support Libraries -- but you
don't have to know that.)
-Luke
More information about the erlang-questions
mailing list