Created
May 26, 2016 00:05
-
-
Save VOID001/c3bb8087faebf729a5238d5b211feb77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************* | |
> 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