[erlang-questions] spawn/4 problem

Serge Aleynikov serge@REDACTED
Sat Mar 10 15:47:07 CET 2007


jaiswal.vikash@REDACTED wrote:
> Hi Serge,
> 
> Thanks for the suggestion.
> Now I'm able to check the return value of "is_process_alive".
> It is returning false .
> 
> Now my question is :
> Since I'm getting false from is_process_alive , it means that the pid
> I'm getting ( due to spawn/4 ) is a dummy pid .

No, it means that the pid is not alive (i.e. the function evaluated in 
the content of the process associated with the Pid exited).

> So how can I get the spawn/4 to give me actual pid instead of the dummy
> .( If I do init 3 followed by init 4 on my system , the spawn/4 starts
> working properly i.e. it does not give dummy but an actual pid ).

There's no such a thing as a dummy Pid.  Spawn always returns a "real" 
Pid of a process located on a local/remote node.  A Pid either 
represents a reference to a live process or a reference to a dead 
process.  In the later case you can use the erlang:is_process_alive/1 
call to see if it's alive.

Serge

> Regards ,
> Vikash 
> 
> -----Original Message-----
> From: Serge Aleynikov [mailto:serge@REDACTED] 
> Sent: Friday, March 09, 2007 5:54 PM
> To: Vikash Jaiswal (WT01 - IP-Multimedia Carrier & Ent Networks)
> Cc: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] spawn/4 problem
> 
> You can only use erlang:is_process_alive/1 for Pids on a local node.  In
> your case the Pid is on a different node.  If you really need to call
> that function use rpc:
> 
> rpc:call(Node, erlang, is_process_alive, [Pid]).
> 
> Serge
> 
> jaiswal.vikash@REDACTED wrote:
>>  
>> Hi ,
>>  
>> I've developed an application which uses spawn/4 .But at some 
>> instances the pid returned by it is a dummy one i.e. that pid does not
> 
>> exist in reality.(i checked it using pman:start().  ). Due to this ,  
>> my application is going into a hanged state  i.e it is sending some 
>> message o the spawned process but not getting any response from it .It
> 
>> is simply waiting for the response .
>>  
>> Could anyone please tell me how I can check whether the pid is real 
>> one or just a dummy ?
>> Also how can I trap the exit signal sent by spawn/4 ? 
>>  
>> Also , when I execute this line in the erl prompt it is working fine 
>> but when I include it in a file I 'm getting the error .
>>          Pid = spawn('abc@REDACTED', my_file, start, []),
>>          erlang:is_process_alive(Pid), The above works  well in erl  
>> prompt but gives the following error when included in the file
>>          =ERROR REPORT==== 9-Mar-2007::14:05:19 === Error in process 
>> <0.30.0> on node 'abc@REDACTED' with exit value:
>> {badarg,[{erlang,is_process_alive,[<5064.11526.6>]},{erl_eval,do_apply
>> ,5
>> },{shell,eval_loop,2}]}
>>  
>> ** exited: {badarg,[{erlang,is_process_alive,[<5064.11526.6>]},
>>                     {erl_eval,do_apply,5},
>>                     {shell,eval_loop,2}]} **
>>   
>>  
>> Thanks in advance .
>>  
>> Regards ,
>> Vikash
>>
>>
>>
>> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> addressee(s) and may contain proprietary, confidential or privileged
> information. If you are not the intended recipient, you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately and destroy all copies of this message and any attachments. 
>> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses.
> The company accepts no liability for any damage caused by any virus
> transmitted by this email.
>>  
>> www.wipro.com
>>
>>
>> ----------------------------------------------------------------------
>> --
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 
> 
> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 
> 
> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>  
> www.wipro.com
> 




More information about the erlang-questions mailing list