version 1.1, 2016/03/30 08:25:43 |
version 1.2, 2016/03/30 09:20:40 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/kan96xx/plugin/mysig.c,v 1.1 2016/03/30 08:25:43 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include <signal.h> |
#include <signal.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#include <string.h> |
#include <string.h> |
#include "mysig.h" |
#include "mysig.h" |
|
|
int unblock_sigchild_sigint(void) { |
/* |
|
sigset SIGINT, SIGCHLD, SIGUSR1 |
|
*/ |
|
int unblock_signal(int sigset[]) { |
struct sigaction act; |
struct sigaction act; |
sigset_t set; |
sigset_t set; |
sigset_t oldset; |
sigset_t oldset; |
|
int i; |
sigemptyset(&set); |
sigemptyset(&set); |
sigaddset(&set,SIGINT); |
for (i=0; sigset[i] > 0; i++) sigaddset(&set,sigset[i]); |
sigaddset(&set,SIGCHLD); |
|
sigprocmask(SIG_UNBLOCK,&set,&oldset); |
sigprocmask(SIG_UNBLOCK,&set,&oldset); |
return(0); |
return(0); |
} |
} |
|
/* Add (or) blocked signals, see sigprocmask */ |
|
int block_signal(int sigset[]) { |
|
struct sigaction act; |
|
sigset_t set; |
|
sigset_t oldset; |
|
int i; |
|
sigemptyset(&set); |
|
for (i=0; sigset[i] > 0; i++) sigaddset(&set,sigset[i]); |
|
sigprocmask(SIG_BLOCK,&set,&oldset); |
|
return(0); |
|
} |
|
|
int set_sigchild(void (*handler)(void)) { |
int set_signal(int sig,void (*handler)(int m)) { |
struct sigaction act; |
struct sigaction act; |
struct sigaction oldact; |
struct sigaction oldact; |
act.sa_handler=handler; |
act.sa_handler=handler; |
act.sa_flags=0; |
act.sa_flags=0; |
act.sa_flags |= SA_RESTART; |
act.sa_flags |= SA_RESTART; |
sigemptyset(&act.sa_mask); |
sigemptyset(&act.sa_mask); |
return(sigaction(SIGCHLD,&act,&oldact)); |
return(sigaction(sig,&act,&oldact)); |
} |
} |
|
|
|
|