int sigismember(const sigset_t *set, int signo) { if (SIGBAD(signo)) { errno = EINVAL; return -1; } return ((*set & (1 << (signo - 1))) != 0); }
int sigaddset(sigset_t *set, int signo) { if (SIGBAD(signo)) { errno = EINVAL; return(-1); } *set |= 1 << (signo - 1); /* turn bit on */ return(0); }
int sigdelset(sigset_t *set, int signo) { if (SIGBAD(signo)) { errno = EINVAL; return(-1); } *set &= ~(1 << (signo - 1)); /* turn bit off */ return(0); }
int sigdelset(sigset_t *set, int signo) { if(SIGBAD(signo)) { error = EINVAL; return -1; } *set &= ~(1 << (signo -1)); /* turn bit off */ return 0; }
int sigaddset(sigset_t *set, int signo) { if (SIGBAD(signo)) { errno = EINVAL; return -1; } *set |= 1 << (signo-1); return 0; }
/* del a signal from set, just turn off that bit */ int sigdelset( sigset_t *set, int signo ) { if ( SIGBAD( signo ) ) { errno = EINVAL; return -1; } *set &= ~(1 << (signo - 1)); return 0; }
/* add a signal to set, just turn on the bit: the signo'th bit */ int sigaddset( sigset_t *set, int signo ) { /* checking for error: invalid signo, for example */ if ( SIGBAD( signo ) ) { errno = EINVAL; return -1; } /* * generally there is no signal 0, so we should substract 1 from signo to get * the designated bit */ *set |= (1 << (signo - 1)); /* turn the bit on */ return 0; }
Sigfunc *_nt_signal(int signal, Sigfunc * handler) { Sigfunc *old; if (SIGBAD(signal)) { errno = EINVAL; return SIG_ERR; } if (signal == SIGHUP && handler == SIG_IGN && __forked) { __nt_child_nohupped = 1; } old = handlers[signal]; handlers[signal] = handler; return old; }
int sigaction(int signo, const struct sigaction *act, struct sigaction *oact) { if (SIGBAD(signo)) { errno = EINVAL; return -1; } if(oact){ oact->sa_handler = handlers[signo]; oact->sa_mask = 0; oact->sa_flags =0; } if ((signo == SIGHUP) && (act && (act->sa_handler == SIG_IGN)) && __forked) __nt_child_nohupped = 1; if (act) handlers[signo]=act->sa_handler; return 0; }
int generic_handler(DWORD signo) { int blocked=0; if (SIGBAD(signo) ) return FALSE; switch (signo) { case SIGINT: if (handlers[signo] != SIG_IGN){ if (fast_sigmember(&gBlockMask,signo) ) { inc_pending(signo); blocked=1; } else if (handlers[signo] == SIG_DFL) ExitProcess(0xC000013AL); else handlers[signo](signo); } break; case SIGBREAK: if (handlers[signo] != SIG_IGN){ if (fast_sigmember(&gBlockMask,signo) ) { inc_pending(signo); blocked=1; } else if (handlers[signo] == SIG_DFL) ExitProcess(0xC000013AL); else handlers[signo](signo); } break; case SIGHUP: //CTRL_CLOSE_EVENT if (handlers[signo] != SIG_IGN){ if (fast_sigmember(&gBlockMask,signo) ) { inc_pending(signo); blocked=1; } else if (handlers[signo] == SIG_DFL) ExitProcess(604); else handlers[signo](signo); } break; case SIGTERM: //CTRL_LOGOFF_EVENT if (handlers[signo] != SIG_IGN){ if (fast_sigmember(&gBlockMask,signo) ) { inc_pending(signo); blocked=1; } else if (handlers[signo] == SIG_DFL) ExitProcess(604); else handlers[signo](signo); } else ExitProcess(604); break; case SIGKILL: //CTRL_SHUTDOWN_EVENT if (handlers[signo] != SIG_IGN){ if (fast_sigmember(&gBlockMask,signo) ) { inc_pending(signo); blocked=1; } else if (handlers[signo] == SIG_DFL) ExitProcess(604); else handlers[signo](signo); } else ExitProcess(604); break; case SIGALRM: if (handlers[signo] != SIG_IGN){ if (fast_sigmember(&gBlockMask,signo) ) { inc_pending(signo); blocked=1; } else if (handlers[signo] == SIG_DFL) ExitProcess(604); else handlers[signo](signo); } break; case SIGCHLD: if (handlers[signo] != SIG_IGN){ if (fast_sigmember(&gBlockMask,signo) ) { dprintf("inc pending for sig %d count %d\n",signo, gPending[signo]); inc_pending(signo); blocked=1; } else if (handlers[signo] != SIG_DFL) handlers[signo](signo); } break; default: ExitProcess(604); break; } if (!blocked && __is_suspended) { EnterCriticalSection(&sigcritter); __is_suspended--; LeaveCriticalSection(&sigcritter); dprintf("releasing suspension is_suspsend = %d\n",__is_suspended); SetEvent(hsigsusp); } return TRUE; }
int sigdelset(sigset_t *set, int signo){ if (SIGBAD(signo)) { errno = EINVAL; return (-1);}/*SIGBAD*/ *set &= ~(1 << (signo - 1)); return 0; }/*sigdelset*/
int sigaddset(sigset_t *set, int signo){ if (SIGBAD(signo)) { errno = EINVAL; return (-1);}/*SIGBAD*/ *set |= 1 << (signo - 1); return 0; }/*sigaddset*/