I haven't completely understood how to use sigprocmask(). Particularly how the set and oldset in its syntax work and how to use them.
int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
Please explain with an example used to block, say SIGUSR1 for a few seconds and then unblock and handle it.
...
Are there any well known reasons for sigprocmask() to segfault when used in a multithreaded application?
I have an application that creates multiple threads using clone(). I have determined that for some reason when I use sigprocmask it segfaults (not all the time though). From the backtrace() it also seems like the segfault is occuring...
I'm using sigprocmask as follows:
void mask(){
sigset_t new_set,old_set;
sigemptyset(&new_set);
sigaddset(&new_set,SIGALRM);
sigprocmask(SIG_BLOCK, &new_set, &old_set);
}
and to my surprise a function which prints a big list somehow gets interrupted by the signal, even though I invoke mask() at its beginning.
It look...