Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

struct sigaction's sa_mask field and sigprocmask() function

Tags:

c

struct sigaction:

struct sigaction {
       void      (*sa_handler)(int);   /* addr of signal handler, */
                                       /* or SIG_IGN, or SIG_DFL */
       sigset_t sa_mask;               /* additional signals to block */
       int      sa_flags;              /* signal options, Figure 10.16 */

       /* alternate handler */
       void     (*sa_sigaction)(int, siginfo_t *, void *);
    };

sigprocmask function:

   int sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict oset);

is that both sa_mask of struct sigaction and sigprocmask() function are able to mask the signal? what is the difference?

like image 936
kevin Avatar asked Aug 31 '25 10:08

kevin


1 Answers

The mask in struct sigaction are signals that will be blocked (in the thread the signal handler executes in) while the signal handler is running.

The mask established with sigprocmask() are the signals that will be blocked for the process (and should only be used in a single threaded program)

like image 171
nos Avatar answered Sep 03 '25 02:09

nos