[BACK]Return to mysig.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / plugin

Annotation of OpenXM/src/kan96xx/plugin/mysig.c, Revision 1.2

1.2     ! takayama    1: /* $OpenXM: OpenXM/src/kan96xx/plugin/mysig.c,v 1.1 2016/03/30 08:25:43 takayama Exp $ */
1.1       takayama    2: #include <stdio.h>
                      3: #include <signal.h>
                      4: #include <unistd.h>
                      5: #include <setjmp.h>
                      6: #include <string.h>
                      7: #include "mysig.h"
                      8:
1.2     ! takayama    9: /*
        !            10:   sigset SIGINT, SIGCHLD, SIGUSR1
        !            11:  */
        !            12: int unblock_signal(int sigset[]) {
1.1       takayama   13:   struct sigaction act;
                     14:   sigset_t set;
                     15:   sigset_t oldset;
1.2     ! takayama   16:   int i;
1.1       takayama   17:   sigemptyset(&set);
1.2     ! takayama   18:   for (i=0; sigset[i] > 0; i++) sigaddset(&set,sigset[i]);
1.1       takayama   19:   sigprocmask(SIG_UNBLOCK,&set,&oldset);
                     20:   return(0);
                     21: }
1.2     ! takayama   22: /* Add (or) blocked signals, see sigprocmask */
        !            23: int block_signal(int sigset[]) {
        !            24:   struct sigaction act;
        !            25:   sigset_t set;
        !            26:   sigset_t oldset;
        !            27:   int i;
        !            28:   sigemptyset(&set);
        !            29:   for (i=0; sigset[i] > 0; i++) sigaddset(&set,sigset[i]);
        !            30:   sigprocmask(SIG_BLOCK,&set,&oldset);
        !            31:   return(0);
        !            32: }
1.1       takayama   33:
1.2     ! takayama   34: int set_signal(int sig,void (*handler)(int m)) {
1.1       takayama   35:   struct sigaction act;
                     36:   struct sigaction oldact;
                     37:   act.sa_handler=handler;
                     38:   act.sa_flags=0;
                     39:   act.sa_flags |= SA_RESTART;
                     40:   sigemptyset(&act.sa_mask);
1.2     ! takayama   41:   return(sigaction(sig,&act,&oldact));
1.1       takayama   42: }
                     43:
                     44:
                     45:
                     46:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>