Skip to content

Instantly share code, notes, and snippets.

@VOID001
Created May 26, 2016 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VOID001/c3bb8087faebf729a5238d5b211feb77 to your computer and use it in GitHub Desktop.
Save VOID001/c3bb8087faebf729a5238d5b211feb77 to your computer and use it in GitHub Desktop.
/*************************************************************************
> 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