Is sa_mask default value empty?

699 Views Asked by At

I'm trying to implement a signal handler and was wondering if I need to explicitly empty sa_mask field of the struct sigaction or if by initializing it with default value is sufficient.

1

There are 1 best solutions below

0
On

Practically, you can initialize the structure to 0 with something like memset() and then initialize the signal handler field:

struct sigaction action;

memset(&action, 0, sizeof(struct sigaction));
action.sa_handler = handler_func;

Theoretically, a typed object like "sigset_t" comes with its proper initialization method. And so, you can't suppose that setting it to 0 through memset() will work. Hence, for this field, you are supposed to use the signal set related routines to manipulate it:

struct sigaction action;

memset(&action, 0, sizeof(struct sigaction));
sigemptyset(&(action.sa_mask));
action.sa_handler = handler_func;