本文整理汇总了C++中ruby_signal函数的典型用法代码示例。如果您正苦于以下问题:C++ ruby_signal函数的具体用法?C++ ruby_signal怎么用?C++ ruby_signal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ruby_signal函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_sigchld
static void
init_sigchld(int sig)
{
sighandler_t oldfunc;
#if USE_TRAP_MASK
# ifdef HAVE_SIGPROCMASK
sigset_t mask;
sigset_t fullmask;
# else
int mask;
int fullmask;
# endif
#endif
#if USE_TRAP_MASK
/* disable interrupt */
sigfillset(&fullmask);
pthread_sigmask(SIG_BLOCK, &fullmask, &mask);
#endif
oldfunc = ruby_signal(sig, SIG_DFL);
if (oldfunc != SIG_DFL && oldfunc != SIG_IGN) {
ruby_signal(sig, oldfunc);
} else {
GET_VM()->trap_list[sig].cmd = 0;
}
#if USE_TRAP_MASK
sigdelset(&mask, sig);
pthread_sigmask(SIG_SETMASK, &mask, NULL);
trap_last_mask = mask;
#endif
}
示例2: install_sighandler
static void
install_sighandler(int signum, sighandler_t handler)
{
sighandler_t old;
old = ruby_signal(signum, handler);
if (old != SIG_DFL) {
ruby_signal(signum, old);
}
}
示例3: ruby_sig_finalize
void
ruby_sig_finalize(void)
{
sighandler_t oldfunc;
oldfunc = ruby_signal(SIGINT, SIG_IGN);
if (oldfunc == sighandler) {
ruby_signal(SIGINT, SIG_DFL);
}
}
示例4: install_sighandler
static void
install_sighandler(int signum, sighandler_t handler)
{
sighandler_t old;
/* At this time, there is no subthread. Then sigmask guarantee atomics. */
rb_disable_interrupt();
old = ruby_signal(signum, handler);
/* signal handler should be inherited during exec. */
if (old != SIG_DFL) {
ruby_signal(signum, old);
}
rb_enable_interrupt();
}
示例5: trap
static VALUE
trap(struct trap_arg *arg)
{
sighandler_t oldfunc, func = arg->func;
VALUE oldcmd, command = arg->cmd;
int sig = arg->sig;
rb_vm_t *vm = GET_VM();
oldfunc = ruby_signal(sig, func);
oldcmd = vm->trap_list[sig].cmd;
switch (oldcmd) {
case 0:
if (oldfunc == SIG_IGN) oldcmd = rb_str_new2("IGNORE");
else if (oldfunc == sighandler) oldcmd = rb_str_new2("DEFAULT");
else oldcmd = Qnil;
break;
case Qundef:
oldcmd = rb_str_new2("EXIT");
break;
}
vm->trap_list[sig].cmd = command;
vm->trap_list[sig].safe = rb_safe_level();
/* enable at least specified signal. */
#if USE_TRAP_MASK
#ifdef HAVE_SIGPROCMASK
sigdelset(&arg->mask, sig);
#else
arg->mask &= ~sigmask(sig);
#endif
#endif
return oldcmd;
}
示例6: trap
static VALUE
trap(int sig, sighandler_t func, VALUE command)
{
sighandler_t oldfunc;
VALUE oldcmd;
rb_vm_t *vm = GET_VM();
/*
* Be careful. ruby_signal() and trap_list[sig].cmd must be changed
* atomically. In current implementation, we only need to don't call
* RUBY_VM_CHECK_INTS().
*/
oldfunc = ruby_signal(sig, func);
oldcmd = vm->trap_list[sig].cmd;
switch (oldcmd) {
case 0:
case Qtrue:
if (oldfunc == SIG_IGN) oldcmd = rb_str_new2("IGNORE");
else if (oldfunc == sighandler) oldcmd = rb_str_new2("DEFAULT");
else oldcmd = Qnil;
break;
case Qnil:
break;
case Qundef:
oldcmd = rb_str_new2("EXIT");
break;
}
vm->trap_list[sig].cmd = command;
vm->trap_list[sig].safe = rb_safe_level();
return oldcmd;
}
示例7: sighandler
static RETSIGTYPE
sighandler(int sig)
{
ATOMIC_INC(signal_buff.cnt[sig]);
ATOMIC_INC(signal_buff.size);
#if !defined(BSD_SIGNAL) && !defined(POSIX_SIGNAL)
ruby_signal(sig, sighandler);
#endif
}
示例8: sighandler
static RETSIGTYPE
sighandler(int sig)
{
signal_enque(sig);
rb_thread_wakeup_timer_thread();
#if !defined(BSD_SIGNAL) && !defined(POSIX_SIGNAL)
ruby_signal(sig, sighandler);
#endif
}
示例9: sighandler
static RETSIGTYPE
sighandler(int sig)
{
rb_vm_t *vm = GET_VM(); /* fix me for Multi-VM */
ATOMIC_INC(vm->signal_buff[sig]);
ATOMIC_INC(vm->buffered_signal_size);
#if !defined(BSD_SIGNAL) && !defined(POSIX_SIGNAL)
ruby_signal(sig, sighandler);
#endif
}
示例10: init_sigchld
static void
init_sigchld(int sig)
{
sighandler_t oldfunc;
#if USE_TRAP_MASK
# ifdef HAVE_SIGPROCMASK
sigset_t mask;
# else
int mask;
# endif
#endif
#if USE_TRAP_MASK
/* disable interrupt */
# ifdef HAVE_SIGPROCMASK
sigfillset(&mask);
sigprocmask(SIG_BLOCK, &mask, &mask);
# else
mask = sigblock(~0);
# endif
#endif
oldfunc = ruby_signal(sig, SIG_DFL);
if (oldfunc != SIG_DFL && oldfunc != SIG_IGN) {
ruby_signal(sig, oldfunc);
} else {
trap_list[sig].cmd = 0;
}
#if USE_TRAP_MASK
#ifdef HAVE_SIGPROCMASK
sigdelset(&mask, sig);
sigprocmask(SIG_SETMASK, &mask, NULL);
#else
mask &= ~sigmask(sig);
sigsetmask(mask);
#endif
trap_last_mask = mask;
#endif
}
示例11: posix_signal
void
posix_signal(int signum, sighandler_t handler)
{
ruby_signal(signum, handler);
}
示例12: posix_signal
sighandler_t
posix_signal(int signum, sighandler_t handler)
{
return ruby_signal(signum, handler);
}
示例13: trap
//.........这里部分代码省略.........
if (strncmp(RSTRING_PTR(command), "EXIT", 4) == 0) {
arg->cmd = Qundef;
}
break;
}
}
}
if (func == SIG_IGN || func == SIG_DFL) {
command = 0;
}
else {
command = arg->cmd;
}
switch (TYPE(arg->sig)) {
case T_FIXNUM:
sig = FIX2INT(arg->sig);
break;
case T_SYMBOL:
s = rb_id2name(SYM2ID(arg->sig));
if (!s) rb_raise(rb_eArgError, "bad signal");
goto str_signal;
case T_STRING:
s = RSTRING_PTR(arg->sig);
str_signal:
if (strncmp("SIG", s, 3) == 0)
s += 3;
sig = signm2signo(s);
if (sig == 0 && strcmp(s, "EXIT") != 0)
rb_raise(rb_eArgError, "unsupported signal SIG%s", s);
}
if (sig < 0 || sig >= NSIG) {
rb_raise(rb_eArgError, "invalid signal number (%d)", sig);
}
#if defined(HAVE_SETITIMER)
if (sig == SIGVTALRM) {
rb_raise(rb_eArgError, "SIGVTALRM reserved for Thread; can't set handler");
}
#endif
if (func == SIG_DFL) {
switch (sig) {
case SIGINT:
#ifdef SIGHUP
case SIGHUP:
#endif
#ifdef SIGQUIT
case SIGQUIT:
#endif
#ifdef SIGALRM
case SIGALRM:
#endif
#ifdef SIGUSR1
case SIGUSR1:
#endif
#ifdef SIGUSR2
case SIGUSR2:
#endif
func = sighandler;
break;
#ifdef SIGBUS
case SIGBUS:
func = sigbus;
break;
#endif
#ifdef SIGSEGV
case SIGSEGV:
func = sigsegv;
break;
#endif
#ifdef SIGPIPE
case SIGPIPE:
func = sigpipe;
break;
#endif
}
}
oldfunc = ruby_signal(sig, func);
oldcmd = trap_list[sig].cmd;
if (!oldcmd) {
if (oldfunc == SIG_IGN) oldcmd = rb_str_new2("IGNORE");
else if (oldfunc == sighandler) oldcmd = rb_str_new2("DEFAULT");
else oldcmd = Qnil;
}
trap_list[sig].cmd = command;
trap_list[sig].safe = rb_safe_level();
/* enable at least specified signal. */
#ifndef _WIN32
#ifdef HAVE_SIGPROCMASK
sigdelset(&arg->mask, sig);
#else
arg->mask &= ~sigmask(sig);
#endif
#endif
return oldcmd;
}