Bug #4765 » remove-signalmask-op.patch
eval_intern.h (working copy) | ||
---|---|---|
void rb_thread_terminate_all(void);
|
||
VALUE rb_vm_top_self();
|
||
VALUE rb_vm_cbase(void);
|
||
void rb_trap_restore_mask(void);
|
||
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
|
||
#define CharNext(p) ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE))
|
thread_pthread.c (working copy) | ||
---|---|---|
static void
|
||
rb_thread_create_timer_thread(void)
|
||
{
|
||
rb_enable_interrupt();
|
||
if (!timer_thread_id) {
|
||
pthread_attr_t attr;
|
||
int err;
|
||
... | ... | |
native_cond_wait(&timer_thread_cond, &timer_thread_lock);
|
||
native_mutex_unlock(&timer_thread_lock);
|
||
}
|
||
rb_disable_interrupt(); /* only timer thread recieve signal */
|
||
}
|
||
static int
|
vm_core.h (working copy) | ||
---|---|---|
#endif
|
||
VALUE rb_iseq_eval(VALUE iseqval);
|
||
VALUE rb_iseq_eval_main(VALUE iseqval);
|
||
void rb_enable_interrupt(void);
|
||
void rb_disable_interrupt(void);
|
||
#if defined __GNUC__ && __GNUC__ >= 4
|
||
#pragma GCC visibility pop
|
||
#endif
|
vm_eval.c (working copy) | ||
---|---|---|
RB_GC_GUARD(desc);
|
||
rb_raise(rb_eArgError, "uncaught throw %s", RSTRING_PTR(desc));
|
||
}
|
||
rb_trap_restore_mask();
|
||
th->errinfo = NEW_THROW_OBJECT(tag, 0, TAG_THROW);
|
||
JUMP_TAG(TAG_THROW);
|
eval.c (working copy) | ||
---|---|---|
JUMP_TAG(TAG_FATAL);
|
||
}
|
||
rb_trap_restore_mask();
|
||
if (tag != TAG_FATAL) {
|
||
EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self, 0, 0);
|
||
}
|
process.c (working copy) | ||
---|---|---|
static void before_exec(void)
|
||
{
|
||
/*
|
||
* signalmask is inherited across exec() and almost system commands don't
|
||
* work if signalmask is blocked.
|
||
*/
|
||
rb_enable_interrupt();
|
||
#ifdef SIGPIPE
|
||
/*
|
||
* Some OS commands don't initialize signal handler properly. Thus we have
|
||
... | ... | |
#endif
|
||
forked_child = 0;
|
||
rb_disable_interrupt();
|
||
}
|
||
#define before_fork() before_exec()
|
||
... | ... | |
void
|
||
rb_syswait(rb_pid_t pid)
|
||
{
|
||
static int overriding;
|
||
#ifdef SIGHUP
|
||
RETSIGTYPE (*hfunc)(int) = 0;
|
||
#endif
|
||
#ifdef SIGQUIT
|
||
RETSIGTYPE (*qfunc)(int) = 0;
|
||
#endif
|
||
RETSIGTYPE (*ifunc)(int) = 0;
|
||
int status;
|
||
int i, hooked = FALSE;
|
||
int err;
|
||
if (!overriding) {
|
||
#ifdef SIGHUP
|
||
hfunc = signal(SIGHUP, SIG_IGN);
|
||
#endif
|
||
#ifdef SIGQUIT
|
||
qfunc = signal(SIGQUIT, SIG_IGN);
|
||
#endif
|
||
ifunc = signal(SIGINT, SIG_IGN);
|
||
overriding = TRUE;
|
||
hooked = TRUE;
|
||
}
|
||
do {
|
||
i = rb_waitpid(pid, &status, 0);
|
||
} while (i == -1 && errno == EINTR);
|
||
err = rb_waitpid(pid, &status, 0);
|
||
} while (err == -1 && errno == EINTR);
|
||
if (hooked) {
|
||
#ifdef SIGHUP
|
||
signal(SIGHUP, hfunc);
|
||
#endif
|
||
#ifdef SIGQUIT
|
||
signal(SIGQUIT, qfunc);
|
||
#endif
|
||
signal(SIGINT, ifunc);
|
||
overriding = FALSE;
|
||
}
|
||
}
|
||
static VALUE
|
signal.c (working copy) | ||
---|---|---|
return signal_buff.size;
|
||
}
|
||
#if USE_TRAP_MASK
|
||
# ifdef HAVE_SIGPROCMASK
|
||
static sigset_t trap_last_mask;
|
||
# else
|
||
static int trap_last_mask;
|
||
# endif
|
||
#endif
|
||
#if HAVE_PTHREAD_H
|
||
#include <pthread.h>
|
||
#endif
|
||
void
|
||
static void
|
||
rb_disable_interrupt(void)
|
||
{
|
||
#if USE_TRAP_MASK
|
||
sigset_t mask;
|
||
sigfillset(&mask);
|
||
sigdelset(&mask, SIGVTALRM);
|
||
sigdelset(&mask, SIGSEGV);
|
||
pthread_sigmask(SIG_SETMASK, &mask, NULL);
|
||
#endif
|
||
}
|
||
void
|
||
static void
|
||
rb_enable_interrupt(void)
|
||
{
|
||
#if USE_TRAP_MASK
|
||
... | ... | |
{
|
||
/* enable interrupt */
|
||
pthread_sigmask(SIG_SETMASK, &arg->mask, NULL);
|
||
trap_last_mask = arg->mask;
|
||
return 0;
|
||
}
|
||
#endif
|
||
void
|
||
rb_trap_restore_mask(void)
|
||
{
|
||
#if USE_TRAP_MASK
|
||
pthread_sigmask(SIG_SETMASK, &trap_last_mask, NULL);
|
||
#endif
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* Signal.trap( signal, command ) -> obj
|
||
... | ... | |
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
|
||
}
|
||
#endif
|
||
- « Previous
- 1
- 2
- Next »