Signal
signal
信号允许进程和内核中断其他进程,一个信号就是一条消息,他通知进程系统中发生了一个某种类型的事件。ctrl+c 是sigint, 终止信号是sigkill,ctrlz是 sigtstp。 发送信号可以用kill函数以及内核检测到一个系统事件。sigkill和sigstop不能捕捉,忽略和修改默认行为。
信号处理程序,任何进程只能收到一个信号,并处理一个信号,如果一个进程有一个带出的信号,但是有其他的信号要被接收,都不会排队等待而简单的被抛弃。临时阻塞信号可以用sigprocmask。
In eval, the parent must use sigprocmask to block SIGCHLD, SIGINT, and SIGTSTP signals before it forks the child, and then unblock these signals, again using sigprocmask after it adds the child to the job list by calling addjob. Since children inherit the blockedvectors of their parents, the child must be sure to then unblock these signals before it executes the new program. The child should also restore the default handlers for the signals that are ignored by the shell.