首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

erlang 监控远道pid

2012-10-24 
erlang 监控远程pid问题1:?在node A上启动一个erlang节点并且等待接收消息,然后在node B上向node A发送一

erlang 监控远程pid

问题1:

?

在node A上启动一个erlang节点并且等待接收消息,然后在node B上向node A发送一条消息:

?

 {java ,'testt@aliyun-18097n'}!ddddd.

?node A 上可以收到消息。

?

但是当使用BIF?is_pid({java,'testt@aliyun-18097n'}). 返回的是false,说明系统不认为{java,'testt@aliyun-18097n'}这个是一个pid。

?

所以在调用下面的命令的时候都会报同样的badarg错误:

?

?

register(remotejava,{java,'testt@aliyun-18097n'}).

?

?

link({java,'testt@aliyun-18097n'}).

都会报这样的错误:

?

** exception error: bad argument     in function  link/1        called as link({java,'testt@aliyun-18097n'})。
?

问题2:

? ? 执行以下命令可以正常执行

?

link( spawn(fun()-> void end))

?

? ? 但是分开执行之后

?

Pid = spawn(fun()-> void end).link(Pid).

?

? ?却报告错误,比较迷惑呀

? ?网上查了erlang的官方文档,http://www.erlang.org/doc/man/erlang.html

?里面对link函数的定义是这样的:

?

??link(Pid) -> true

Types:Pid = pid() | port()Creates a link between the calling process and another process (or port) Pid, if there is not such a link already. If a process attempts to create a link to itself, nothing is done. Returns true.If Pid does not exist, the behavior of the BIF depends on if the calling process is trapping exits or not (see process_flag/2):If the calling process is not trapping exits, and checking Pid is cheap -- that is, if Pid is local -- link/1 fails with reason noproc.Otherwise, if the calling process is trapping exits, and/or Pid is remote, link/1 returns true, but an exit signal with reason noproc is sent to the calling process.

?

至于为什么,待续

热点排行