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

안녕하세요, 감사합니다

하지만, 그건 그냥 나에게 다음과 같은 오류를 제공합니다. 나는 빈 세트를 가지고 갔다. 벌금과 이번 valgrind는 불평하지 않았다. – ant2009

관련 문제