Skip to content
Snippets Groups Projects
Commit fd1e758e authored by iliya's avatar iliya
Browse files

jad, debrouille toi

parent d54a5d53
No related branches found
No related tags found
No related merge requests found
...@@ -8,17 +8,34 @@ volatile sig_atomic_t count = 0; ...@@ -8,17 +8,34 @@ volatile sig_atomic_t count = 0;
struct sigaction usr1; struct sigaction usr1;
static void handler_usr1(int __attribute__((unused)) signum) { static void handler_usr1(int __attribute__((unused)) signum) {
// if (sigismember(&usr1.sa_mask, SIGTSTP) == 1) {
// fprintf(stdout, "SIGTSTP will be unblocked...\n");
//
// if (sigdelset(&usr1.sa_mask, SIGTSTP) == -1) {
// perror("sigdelset");
// }
// } else if (sigismember(&usr1.sa_mask, SIGTSTP) == 0) {
// fprintf(stdout, "SIGTSTP will be blocked...\n");
//
// if (sigaddset(&usr1.sa_mask, SIGTSTP) == -1) {
// perror("sigaddset");
// }
// } else {
// perror("sigismember");
// }
if (sigismember(&usr1.sa_mask, SIGTSTP) == 1) { if (sigismember(&usr1.sa_mask, SIGTSTP) == 1) {
fprintf(stdout, "SIGTSTP will be unblocked...\n"); fprintf(stdout, "SIGTSTP will be unblocked...\n");
if (sigprocmask(SIG_UNBLOCK, &usr1.sa_mask, NULL) == -1) {
if (sigdelset(&usr1.sa_mask, SIGTSTP) == -1) { perror("sigprocmask");
perror("sigdelset");
} }
sigaddset(&usr1.sa_mask, SIGTSTP);
} else if (sigismember(&usr1.sa_mask, SIGTSTP) == 0) { } else if (sigismember(&usr1.sa_mask, SIGTSTP) == 0) {
fprintf(stdout, "SIGTSTP will be blocked...\n"); fprintf(stdout, "SIGTSTP will be blocked...\n");
if (sigaddset(&usr1.sa_mask, SIGTSTP) == -1) { sigaddset(&usr1.sa_mask, SIGTSTP);
perror("sigaddset"); if (sigprocmask(SIG_BLOCK, &usr1.sa_mask, NULL) == -1) {
perror("sigprocmask");
} }
} else { } else {
perror("sigismember"); perror("sigismember");
...@@ -34,6 +51,8 @@ int main(void) { ...@@ -34,6 +51,8 @@ int main(void) {
usr1.sa_flags = 0; usr1.sa_flags = 0;
sigemptyset(&usr1.sa_mask); sigemptyset(&usr1.sa_mask);
sigprocmask(SIG_BLOCK, &usr1.sa_mask, NULL);
if (sigaddset(&usr1.sa_mask, SIGTSTP) == -1) { if (sigaddset(&usr1.sa_mask, SIGTSTP) == -1) {
perror("sigaddset"); perror("sigaddset");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment