2008 December 19th Friday

   The design of the new porject was not past.  Somethings I understood wrong.  Today I have to modify the design.

Emitting Exit Signals

  When a process terminates, it will terminate with an exit reason as explained in Process Termination above. This exit reason is emitted
in an exit signal to all linked processes.

  A process can also call the function exit(Pid,Reason). This will result in an exit signal with exit reason Reason being emitted to Pid,
but does not affect the calling process.

Receiving Exit Signals

  The default behaviour when a process receives an exit signal with an exit reason other than normal, is to terminate and in turn emit exit
signals with the same exit reason to its linked processes. An exit signal with reason normal is ignored.

  A process can be set to trap exit signals by calling:

process_flag(trap_exit, true)

  When a process is trapping exits, it will not terminate when an exit signal is received. Instead, the signal is transformed into a message
{'EXIT',FromPid,Reason} which is put into the mailbox of the process just like a regular message.

  An exception to the above is if the exit reason is kill, that is if exit(Pid,kill) has been called. This will unconditionally terminate
the process, regardless of if it is trapping exit signals or not.

Receiving Exit Signals

  An alternative to links are monitors. A process Pid1 can create a monitor for Pid2 by calling the BIF erlang:monitor(process, Pid2).
The function returns a reference Ref.

  If Pid2 terminates with exit reason Reason, a 'DOWN' message is sent to Pid1:

{'DOWN', Ref, process, Pid2, Reason}

  If Pid2 does not exist, the 'DOWN' message is sent immediately with Reason set to noproc.

  Monitors are unidirectional. Repeated calls to erlang:monitor(process, Pid) will create several, independent monitors and each one will
send a 'DOWN' message when Pid terminates.

  A monitor can be removed by calling erlang:demonitor(Ref).

  It is possible to create monitors for processes with registered names, also at other nodes.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值