FreeBSD内核读书笔记-4.7-2

2009-05-13 05:14:31来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

【The Design and Implementation of The FreeBSD Operating System】
4.7 Signals 笔记 2

【The work of psignal() is a patchwork of special cases required by the process-debugging and job-control facilities and by intrinsic properties associated with signals. The steps involved in posting a signal are as follows:】

【1、Determine the action that the receiving process will take when the signal is delivered. This information is kept in the p_sigignore and p_sigcatch fields of the process's process structure. If a process is not ignoring or catching a signal, the default action is presumed to apply. If a process is being traced by its parent—that is, by a debugger—the parent process is always permitted to intercede before the signal is delivered. If the process is ignoring the signal, psignal()'s work is done and the routine can return.】

在FreeBSD6.1中,上述处理的代码在do_tdsignal()函数中。

---------------------------------------------------------------------FreeBSD6.1
1704  /*
1705   * If the signal is being ignored,
1706   * then we forget about it immediately.
1707   * (Note: we don't set SIGCONT in ps_sigignore,
1708   * and if it is set to SIG_IGN,
1709   * action will be SIG_DFL here.)
1710   */
1711  mtx_lock(&ps->ps_mtx);
1712  if (SIGISMEMBER(ps->ps_sigignore, sig) ||
1713          (p->p_flag & P_WEXIT)) {
1714      mtx_unlock(&ps->ps_mtx);
1715      return;
1716  }
1717  if (SIGISMEMBER(td->td_sigmask, sig))
1718      action = SIG_HOLD;
1719  else if (SIGISMEMBER(ps->ps_sigcatch, sig))
1720      action = SIG_CATCH;
1721  else
1722      action = SIG_DFL;
1723  if (SIGISMEMBER(ps->ps_sigintr, sig))
1724      intrval = EINTR;
1725  else
1726      intrval = ERESTART;
1727  mtx_unlock(&ps->ps_mtx);
-----------------------------------------------------------/sys/kern/kern_sig.c
首先来看SIGISMEMBER宏,其定义如下:
---------------------------------------------------------------------FreeBSD6.1
130 #define SIGISMEMBER(set, signo) \
131     ((set).__bits[_SIG_WORD(signo)] & _SIG_BIT(signo))
-----------------------------------------------------------/sys/sys/signalvar.h
其中,_SIG_WORD()和_SIG_BIT()宏以及__sigset类型的定义为:
---------------------------------------------------------------------FreeBSD6.1
44 #define _SIG_WORDS 4
......
46 #define _SIG_IDX(sig) ((sig) - 1)
47 #define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
48 #define _SIG_BIT(sig) (1  (_SIG_IDX(sig) & 31))

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:OpenLDAP学习笔记

下一篇:locale