Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*************************************************************************
> File Name: sigset_1.c
> Author: VOID_133
> ###################
> Mail: ###################
> Created Time: Thu 26 May 2016 07:32:22 AM CST
************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<signal.h>
void printsigset(const sigset_t *p)
{
int i = 0;
for(i = 1; i < 32; i++)
{
if(sigismember(p, i) == 1)
putchar('1');
else
putchar('0');
}
puts("");
}
int main(void)
{
printf("This program will run forever, you cannot stop it\n");
printf("If you are sure to run it, press enter, else Ctrl + C NOW");
getchar();
sigset_t set, p;
//Init the signal
sigfillset(&set);
//Add signals
alarm(5);
sigprocmask(SIG_BLOCK, &set, NULL);
while(1)
{
sigpending(&p);
printsigset(&p);
sleep(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.