unix环境高级编程_信号函数定义
2011-04-26 10:00
453 查看
![endif]-->!-->![endif]-->!-->![endif]-->!-->
四、kill, raise, alarm和sleep4.1kill函数int kill(pid_t pid, int signo)POSIX.1定义,将信号发送给进程或进程组,成功返回0,失败返回-1.#pid > 0 将信号发送给进城ID为pid的进程#pid == 0 将信号发送给同进程组的其他所有进程#pid < 0 将信号发送给其进程组ID等于pid绝对值的进程组的所有进程#pid == -1 未定义 4.2raise函数int raise( int signo )ANSI C定义,将信号发送给进程自,成功返回0,失败返回-1. 4.3alarm函数Unsigned int alarm(unsigned seconds)使用alarm函数设置一个时间值,在将来的某个时刻时间值被超过后,产生SIGALARM信号。如果不忽略或不捕捉此信函,则其默认动作是终止该进程。每个进程只能设置一个alarm。如果在调用alarm时,以前已为该进程设置过闹钟时间,而且它还没有超时,则该闹钟时间的余留时间值作为本次alarm函数调用的值返回。以前登记过得闹钟时间则被新值所替换。 4.4pause函数Int pause(void);Pause函数使调用进程挂起直至捕捉到一个信号。只有在执行了一个信号处理程序并从其返回时,pause才返回,在这种情况下,pause返回-1,errno设置为EINTR. 4.5sigaction函数int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);The sigaction()system call is used to change the action taken by a process onreceipt of aspecific signal.signum specifies the signal and can be any valid signal except SIGKILL andSIGSTOP.If act isnon-null, the new action for signal signum is installed from act. If oldact isnon-null, the previous action is saved in oldact. 4.6非局部转移函数Sigsetjmp和siglongjmp,用在信号处理中的非局部转移。非信号处理中使用setjmp和longjmp来进行非局部转移。 4.7abort函数Void abort(void)此函数将SIGABRT信号发送给调用进程,进程不忽略此信号。 五、信号集5.1 sigemptyset函数int sigemptyset(sigset_t *set)sigemptyset()initializes the signal set given by set to empty, with all signalsexcluded from the set. 5.2sigfillset函数Int sigfillset(sigset_t* set)sigfillset()initializes set to full, including all signals. 5.3sigaddset函数和sigdelset函数int sigaddset(sigset_t *set, int signum)int sigdelset(sigset_t *set, int signum)sigaddset() andsigdelset() add and delete respectively signal signum from set. 5.4sigismember函数int sigismember(const sigset_t *set, int signum);sigismember()tests whether signum is a member of set. 5.5sigprocmask函数int sigprocmask(int how, const sigset_t *set,sigset_t *oldset);一个进程的信号屏蔽字规定了当前阻塞而不能传递给该进程的信号集。调用此函数则可以检测或更改进程的信号屏蔽字。 5.6sigpending函数int sigpending(sigset_t *set);调用此函数返回调用进程被阻塞而不能递送和当前未决的信号集。该信号集通过set参数返回。 5.7sigsuspend函数int sigsuspend(const sigset_t *mask);sigsuspend() temporarily replaces the signal mask of the calling process with the mask given bymask and then suspends the process until delivery of a signal whose action isto invoke a signal handler or to terminate a process.If the signal terminates the process, then sigsuspend()does not return. If the signal is caught, then sigsuspend() returns after the signal handler returns, and the signal mask is restored to the state before the call to sigsuspend().It is not possible to block SIGKILL orSIGSTOP; specifying these signals in mask, has no effect onthe process
四、kill, raise, alarm和sleep4.1kill函数int kill(pid_t pid, int signo)POSIX.1定义,将信号发送给进程或进程组,成功返回0,失败返回-1.#pid > 0 将信号发送给进城ID为pid的进程#pid == 0 将信号发送给同进程组的其他所有进程#pid < 0 将信号发送给其进程组ID等于pid绝对值的进程组的所有进程#pid == -1 未定义 4.2raise函数int raise( int signo )ANSI C定义,将信号发送给进程自,成功返回0,失败返回-1. 4.3alarm函数Unsigned int alarm(unsigned seconds)使用alarm函数设置一个时间值,在将来的某个时刻时间值被超过后,产生SIGALARM信号。如果不忽略或不捕捉此信函,则其默认动作是终止该进程。每个进程只能设置一个alarm。如果在调用alarm时,以前已为该进程设置过闹钟时间,而且它还没有超时,则该闹钟时间的余留时间值作为本次alarm函数调用的值返回。以前登记过得闹钟时间则被新值所替换。 4.4pause函数Int pause(void);Pause函数使调用进程挂起直至捕捉到一个信号。只有在执行了一个信号处理程序并从其返回时,pause才返回,在这种情况下,pause返回-1,errno设置为EINTR. 4.5sigaction函数int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);The sigaction()system call is used to change the action taken by a process onreceipt of aspecific signal.signum specifies the signal and can be any valid signal except SIGKILL andSIGSTOP.If act isnon-null, the new action for signal signum is installed from act. If oldact isnon-null, the previous action is saved in oldact. 4.6非局部转移函数Sigsetjmp和siglongjmp,用在信号处理中的非局部转移。非信号处理中使用setjmp和longjmp来进行非局部转移。 4.7abort函数Void abort(void)此函数将SIGABRT信号发送给调用进程,进程不忽略此信号。 五、信号集5.1 sigemptyset函数int sigemptyset(sigset_t *set)sigemptyset()initializes the signal set given by set to empty, with all signalsexcluded from the set. 5.2sigfillset函数Int sigfillset(sigset_t* set)sigfillset()initializes set to full, including all signals. 5.3sigaddset函数和sigdelset函数int sigaddset(sigset_t *set, int signum)int sigdelset(sigset_t *set, int signum)sigaddset() andsigdelset() add and delete respectively signal signum from set. 5.4sigismember函数int sigismember(const sigset_t *set, int signum);sigismember()tests whether signum is a member of set. 5.5sigprocmask函数int sigprocmask(int how, const sigset_t *set,sigset_t *oldset);一个进程的信号屏蔽字规定了当前阻塞而不能传递给该进程的信号集。调用此函数则可以检测或更改进程的信号屏蔽字。 5.6sigpending函数int sigpending(sigset_t *set);调用此函数返回调用进程被阻塞而不能递送和当前未决的信号集。该信号集通过set参数返回。 5.7sigsuspend函数int sigsuspend(const sigset_t *mask);sigsuspend() temporarily replaces the signal mask of the calling process with the mask given bymask and then suspends the process until delivery of a signal whose action isto invoke a signal handler or to terminate a process.If the signal terminates the process, then sigsuspend()does not return. If the signal is caught, then sigsuspend() returns after the signal handler returns, and the signal mask is restored to the state before the call to sigsuspend().It is not possible to block SIGKILL orSIGSTOP; specifying these signals in mask, has no effect onthe process
相关文章推荐
- UNIX环境高级编程第10章信号10.3singal函数
- unix 环境高级编程 信号二 可重入函数与不可重入函数
- Unix环境高级编程(阅读笔记)----信号集、信号屏蔽函数sigprocmask
- unix 环境高级编程 信号函数杂记一
- unix环境高级编程-alarm、pause()与信号处理函数
- UNIX环境高级编程——标准I/O库函数和Unbuffered I/O函数
- UNIX环境高级编程——网络编程常用函数及结构
- unix环境高级编程-信号(2)
- UNIX环境高级编程学习之第十章信号-信号集的操作,让进程阻塞SIGQUIT信号
- UNIX环境高级编程1.9信号
- unix环境高级编程(信号)
- UNIX环境高级编程-第10章- 信号 - 一
- UNIX环境高级编程——标准I/O库函数和Unbuffered I/O函数
- Unix 环境高级编程-----文件操作函数
- unix环境高级编程----进程控制fock()函数
- unix环境高级编程一书中部分错误处理函数
- UNIX环境高级编程(第10章 信号)
- 【UNIX环境高级编程】信号安全——可重入函数
- UNIX环境高级编程------10 信号
- Unix环境高级编程(十)信号续