1、在Unix系统中,signal是可以随时出现的。因此,Unix中的process就告诉kernel “如果出现signal,就去做下面这些事情”。
2、signal 是由谁发出的:terminal-generated signals, hardware exceptions, kill(2) function, kill(1) command, software condition
signal 是发送给谁的:to some process
signal 由谁来处理:应该是kernel
signal 怎么处理:Ignore(不能是SIGKILL SIGSTOP), Catch(不能是SIGKILL SIGSTOP), Default action
3、对于一个process,如果它使用exec变成了另外一个process,那么它所设定的signal handler(即signal()函数中的func指针)都会被重置。
4、对于一个process,如果它使用fork新产生一个child process,那么这个child会继承parent的所有signal disposition(signal action)。
5、The action for a signal was reset to its default each time the signal occurred. (Unreliable signal)
6、If a “slow” system call was blocked and a signal was caught by this process, then the system call was interrupted. Some implementations automaticlly restart the system call, some do not.
7、我们在自己所写的函数中,如果想要UNBLOCK一个signal,我们必须先使用sigprocmask(SIG_BLOCK, &newmask, &oldmask); 获得以前的signal mask,然后再使用SIG_SETMASK重新载入以前的这个值。这是因为,在调用我们所写的这个函数之前,caller可能已经把这个的signal设定为了blocked.
8、使用sigprocmask()对一个signal unblock的时候,这个signal会delivered before the sigprocmask returns.
9、现代系统中,使用sigaction()取代signal()函数,对一个signal设定它的singal handler.
10、setjmp() 和 longjmp()两个函数对于signal mask是否恢复,在不同的Implementation上有不同的实现。所以使用sigsetjmp() 和 siglongjmp()两个函数用在signal handler中。
11、sigsuspend() is used to unblock a signal then go to sleep, waiting that signal to occur.
To protect a critical region of code from a specific signal.
Another use of this function is to wait for a signal handler to set a global variable.