From man sigprocmask
:
"If oset is not null, it is set to the previous value of the signal mask."
My questions: Without running or debugging the program,
After executing line 10, the value of the old signal mask is stored into
y
. Since there were no blocked signals before this line was executed, what is the value ofy
?Is there a way to determine the value of
z
after executing line 14?
1 void my_sig_handler(int sig){
2 write(1, "a", 1);
3 }
4 int main(){
5 signal(SIGINT, my_sig_handler);
6 sigset_t x, y, z;
7 sigemptyset(&x);
8 sigaddset(&x, SIGINT);
9
10 sigprocmask(SIG_BLOCK, &x, &y);
11 write(1,"1",1);
12 do_some_work();
13 write(1,"2",1);
14 sigprocmask(SIG_SETMASK, &y, &z);
15
16 exit(0);
17 }