Alfred
Alfred

Reputation: 1673

Signal Handling in Unix

I am learning Signal handling in Unix and having a hard time understanding what are SIG_SETMASK and o_set in sigprocmask() and what do they do?

I understand that set contains the list of signals to be blocked or unblocked and SIG_BLOCK blocks the signals in the list and SIG_UNBLOCK unblocks them.

sigprocmask(SIG_SETMASK,&set,& o_set);

Upvotes: 0

Views: 268

Answers (1)

Mat
Mat

Reputation: 206929

The Linux manpage explains this well.

The previous value of the signal mask is stored in the last parameter (the old set) if that parameter is non-null.

SIG_SETMASK sets the current signal set. I'm not sure what more there is to say about that - SIG_BLOCK and SIG_UNBLOCK combine the current signal mask with the second parameter, SIG_SETMASK sets it regardless of the current value.

POSIX explains it like this:

SIG_BLOCK
The resulting set shall be the union of the current set and the signal set pointed to by set. SIG_SETMASK
The resulting set shall be the signal set pointed to by set.
SIG_UNBLOCK
The resulting set shall be the intersection of the current set and the complement of the signal set pointed to by set.

Upvotes: 3

Related Questions