常用的信號函數

信號集

<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返回,並且該進程的信號屏蔽字設置爲調用它之前的值

 

發佈了12 篇原創文章 · 獲贊 1 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章