Signal handling and sigemptyset()

后端 未结 3 1963
轮回少年
轮回少年 2020-12-24 07:28

Could anyone please explain in a really easy way to understand what sigemptyset() does? Why is it useful? I\'ve read a bunch of definitions but i just don\'t understand. Fro

3条回答
  •  有刺的猬
    2020-12-24 08:10

    The name says it all. sigemptyset() empties (a variable describing) a set of signals.

    That is

    sigset_t ss;
    sigemptyset(&ss);
    

    initialises a variable of type sigset_t (ss here) to "contain" no signals.

    From man sigemptyset (Linux):

    sigemptyset() initializes the signal set given by set to empty, with all signals excluded from the set.

    [...]

    Objects of type sigset_t must be initialized by a call to either sigemptyset() or sigfillset() before being passed to the functions sigaddset(), sigdelset() and sigismember() [...]

    From the POSIX specs:

    int sigemptyset(sigset_t *set); 
    

    [...]

    The sigemptyset() function initializes the signal set pointed to by set, such that all signals defined in POSIX.1-2008 are excluded.

提交回复
热议问题