首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

常用的信号函数

Posted on 2009-11-01 22:52  放飞自我  阅读(610)  评论(0编辑  收藏  举报

信号集

<signal.h>

int sigemptyset( sigset_t *set)

int sigfillset(sigset_t *set)

int sigaddset(sigset_t *set, int signum)

int sigdelset(sigset_t *set, int signum)

int sigismember(const sigset_t *set, int signum)

 

int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)

SIG_BLOCK 

The set of blocked signals is the union of the current set and the set argument

SIG_UNBLOCK

The signals in set are removed from the current set of blocked signals. It is legal to attempt to unblock a signal which is not blocked.

SIG_SETMASK

The set of blocked signals is set to the argument set.

If oldset is non-null, the previous value of the signal mask is stored in oldset.

If set is NULL, then the signal mask is unchanged (i.e., how is ignored), but the current value ofthe signal mask is nevertheless returned in oldset (it is not NULL). The use of sigprocmask() is unspecified in a multithreaded process

 

int sigpending( sigset_t *set)      成功0;出错-1

返回对于调用进程被阻塞不能递送和当前未决的信号集

 

int sigaction( int signo, const struct sigaction *act, struct sigaction * oact) 成功0,失败-1

signo是要检测或修改具体动作的信号编号数,若act为非空,则要修改其动作;如果oact非空,则系统返回该信号的原先动作

struct sigaction{

       void       (*sa_handler) ();

       sigset_t   sa_mask;

       int           sa_flags;

}

 

<setjmp.h>

int segsetjmp( sigjmp_buf env, int savemask) 直接调用返回0,从siglongjmp返回非0

void siglongjmp(sigjmp_buf , int val)

如果savemask0,保存进程当前信号屏蔽字

 

<signal.h>

int sigsuspend( const sigset_t *sigmask)

进程的信号屏蔽字设置为sigmask指向的值,在捕捉到一个信号或发生一个会终止该进程的信号之前,该进程被挂起。如果捕捉到一个信号而且从该信号处理程序返回,则sigsuspend返回,并且该进程的信号屏蔽字设置为调用它之前的值