2012-02-17 56 views
1

在erlang shell中創建了三個erlang進程並在本地註冊,名爲Pid,Pid2,Pid3。然後我想通過函數「exit/2」來終止「Pid」。在erlang shell中使用「exit/2」函數

([email protected])62> exit(lsaaa_dispatch,test). %lsaaa_dispatch is the above Pid's local registered name 
** exception error: bad argument 
    in function exit/2 
     called as exit(lsaaa_dispatch,test) 

爲什麼發生異常? 爲什麼所有這三個過程都終止?因爲我在Pman找不到他們。

回答

0

exit/2接受一個PID,而不是一個術語。它由內核'erlang'模塊定義。

exit(whereis(lsaaa_dispatch), test). 

你的第二個問題,認爲這些過程與外殼的關係。

+1

是的,如果3個進程鏈接到shell進程,那麼當shell中有錯誤時,它們將全部死亡。 shell中的所有錯誤都會導致shell進程死亡;一個新的會自動啓動給你,所以在很多方面你都沒有注意到它。除了殺死鏈接進程。注:這不是一個錯誤,而是它打算如何工作。 – rvirding 2012-02-18 12:22:42