I was told that every time I want to use sigset_t block_mask
, I also need to use the sigemptyset()
function before I use sigaddset()
. For example:
sigset_t block_mask;
sigemptyset(&block_mask);
sigaddset(&block_mask, SIGSEGV);
Why do I need to do it every time?
sigaddset
changes a single signal in the set, but leaves the information about all other signals unaffected. Without sigemptyset
, that other information would not have been initialized.
Think of a signal set as a bitmask, something like this:
sigset_t block_mask; int block_mask;
sigemptyset(&block_mask); block_mask = 0;
sigaddset(&block_mask, SIGSEGV); block_mask |= 1 << SIGSEGV;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.