what is the correct values to assign to sa_mask field of sigaction struct

486 Views Asked by At
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>

void sigint_handler(int sig) {
  write(0, "nice try\n", 10);
}
int main(void) {
  struct sigaction sa; // configure sigaction
  sa.sa_handler=sigint_handler;
  sa.sa_flags=0;
  sa.sa_mask=0;
  if (sigaction(SIGINT, & sa, NULL) == -1) { // set handler
    perror("sigaction");
    exit(1);
  }
  printf("You shall not exit!\n");
  while (1) {
    sleep(1);
  }
}

The above code when compiled with g++ gives the error :

sigaction.c:13:14: error: no match for ‘operator=’ (operand types are ‘__sigset_t’ and
 ‘int’)
   13 |   sa.sa_mask=0;
      |              ^
In file included from /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:4,
                 from /usr/include/x86_64-linux-gnu/sys/select.h:33,
                 from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:394,
                 from /usr/include/c++/9/cstdlib:75,
                 from /usr/include/c++/9/stdlib.h:36,
                 from sigaction.c:2:

In the man pages for sigaction its defined as sigset_t sa_mask; I am not sure what this sigset_t is exactly. What could be possible values for it.

0

There are 0 best solutions below