2011-08-06 3 views
4

gccが(GCC)4.6.0 C89sigset_tにsa_maskを設定するには?

私は、シグナルハンドラは次のように宣言している:

/* Setup signal handler */ 
    struct sigaction new_action; 
    new_action.sa_handler = g_signal_handler; 
    new_action.sa_flags = SA_ONSTACK; 

    if(sigaction(SIGINT, &new_action, NULL) == -1) { 
     fprintf(stderr, "Failed to setup signal handlers."); 
     return -1; 
    } 

私はそれが次のエラー拾っvalgrind --leak-check=fullつまりvalgrindの経由私のコードを実行していた:

==5206== Syscall param rt_sigaction(act->sa_mask) points to uninitialised byte(s) 
==5206== at 0x347A435455: __libc_sigaction (in /lib64/libc-2.14.so) 

だからでテストするために、私は次のように設定することを決定したmanページを見てaftering:

new_action.sa_mask = SA_NODEFER;任意の提案のための

error: incompatible types when assigning to type ‘__sigset_t’ from type ‘int’ 

多くのおかげで、

答えて

10

はこれを試してみてください:

/* Signals blocked during the execution of the handler. */ 
sigemptyset(&new_action.sa_mask); 
sigaddset(&new_action.sa_mask, SIGINT); 

The sa_mask field allows us to specify a set of signals that aren’t permitted to interrupt execution of this handler. In addition, the signal that caused the handler to be invoked is automatically added to the process signal mask.

+0

こんにちは、おかげ

しかし、それはちょうど私に次のエラーを与えます。私は空のセットと一緒に行った。うまくいきましたが、今回はバングラデントが文句を言っていませんでした。 – ant2009

関連する問題