2012-02-17 36 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