[erlang-questions] Re: erl startup

Bernard Duggan bernie@REDACTED
Wed Jun 2 02:37:36 CEST 2010


On 02/06/10 08:43, Wes James wrote:
> [snip]
>> wait_for_exit() ->
>>         receive
>>                 some_exit_signal ->    ok;
>>                 _ ->    wait_for_exit()
>>         end.
>>
>>      
> If I do this
>
>   module:wait_for_exit() ! some_exit_signal.
>
> It just hangs.  I have to hit ctrl-c to kill it.  Isn't it supposed to
> exit wait_for_exit() after that?
>    
...No?  What you're asking it to do there is to send the message 
'some_exit_signal' to the process returned by the call 
module:wait_for_exit().  That function doesn't return a process - 
indeed, its whole point is to /not return at all/ until it receives that 
message.
You need to get the PID of the process that's running (the value 
returned by start()) and send the signal to that.  ie:

1> Pid = module:start().
<some pid>
2> Pid ! some_exit_signal.

B


More information about the erlang-questions mailing list