[erlang-questions] How to detect that spawn/4 did not work

Loïc Hoguin essen@REDACTED
Fri Aug 8 22:27:18 CEST 2014


Well spawn is "start and forget". If you need to know that the process 
is alive as intended you need a link or a monitor. It's the same with 
local processes, even if the process starts it may immediately crash, 
and the only way to know that is by using monitors or links.

On 08/08/2014 10:06 PM, Federico Carrone wrote:
> How can we detect that spawn/4 did not work (network split, host down,
> etc)? We get an error report but the function returns an invalid Pid and
> it is not possible to know if it is a real one or not.
>
> Why does it return a pid even if it did not work and if it can detect
> the error (since it generated an error report)?
>
> Regards,
> Federico.
>
> ---
>
> 1> spawn('this.is@REDACTED', erlang, display, [nothing]).
> <0.43.0>
>
> =ERROR REPORT==== 8-Aug-2014::16:50:52 ===
> ** Can not start erlang:display,[nothing] on 'this.is@REDACTED' **
>
> 2> proc_lib:spawn('this.is@REDACTED', erlang, display, [nothing]).
> <0.56.0>
>
> 3>
> =ERROR REPORT==== 8-Aug-2014::16:52:21 ===
> ** Can not start proc_lib:init_p,[<0.50.0>,[],erlang,display,[nothing]]
> on 'this.is@REDACTED' **
>
> 4> is_process_alive(spawn('this.is@REDACTED', erlang, display,
> [nothing])).
> true
> 5>
> =ERROR REPORT==== 8-Aug-2014::16:53:27 ===
> ** Can not start erlang:display,[nothing] on 'this.is@REDACTED' **
>
> --
> http://federicocarrone.com/
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>

-- 
Loïc Hoguin
http://ninenines.eu



More information about the erlang-questions mailing list