Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Functions | Variables
signal.c File Reference
`#include "ruby/ruby.h"`
`#include "vm_core.h"`
`#include <signal.h>`
`#include <stdio.h>`
`#include <errno.h>`
`#include "ruby_atomic.h"`
`#include "eval_intern.h"`
Include dependency graph for signal.c:

Go to the source code of this file.

## Data Structures
struct | signals

## Macros
#define | killpg(pg, sig) kill(-(pg), (sig))
#define | SIGINFO_ARG
#define | ruby_signal(sig, handler) (/* rb_trap_accept_nativethreads[(sig)] = 0,*/ signal((sig),(handler)))
#define | CHECK_STACK_OVERFLOW() (void)0
#define | ruby_enable_coredump 0

## Typedefs
typedef RETSIGTYPE(* | sighandler_t )(int)
typedef RETSIGTYPE | ruby_sigaction_t (int)

## Functions
rb_atomic_t | ruby_atomic_exchange (rb_atomic_t *ptr, rb_atomic_t val)
rb_atomic_t | ruby_atomic_compare_and_swap (rb_atomic_t *ptr, rb_atomic_t cmp, rb_atomic_t newval)
static int | signm2signo (const char *nm)
static const char * | signo2signm (int no)
static VALUE | sig_signame (VALUE recv, VALUE signo)
const char * | ruby_signal_name (int no)
static VALUE | esignal_init (int argc, VALUE *argv, VALUE self)
static VALUE | esignal_signo (VALUE self)
static VALUE | interrupt_init (int argc, VALUE *argv, VALUE self)
void | ruby_default_signal (int sig)
VALUE | rb_f_kill (int argc, VALUE *argv)
static RETSIGTYPE | sighandler (int sig)
int | rb_signal_buff_size (void)
static void | rb_disable_interrupt (void)
static void | rb_enable_interrupt (void)
int | rb_get_next_signal (void)
static void | signal_exec (VALUE cmd, int safe, int sig)
void | rb_trap_exit (void)
void | rb_signal_exec (rb_thread_t *th, int sig)
static sighandler_t | default_handler (int sig)
static sighandler_t | trap_handler (VALUE *cmd, int sig)
static int | trap_signm (VALUE vsig)
static VALUE | trap (int sig, sighandler_t func, VALUE command)
static int | reserved_signal_p (int signo)
static VALUE | sig_trap (int argc, VALUE *argv)
static VALUE | sig_list (void)
static void | install_sighandler (int signum, sighandler_t handler)
void | ruby_sig_finalize (void)
void | Init_signal (void)

## Variables
static struct signals | siglist []
struct {
rb_atomic_t cnt [RUBY_NSIG]
rb_atomic_t size
} | signal_buff
int | ruby_enable_coredump = 0

## Macro Definition Documentation

#define CHECK_STACK_OVERFLOW | ( |  | ) | (void)0

Definition at line 621 of file signal.c.

#define killpg | ( |  | pg,
|  |  | sig
| ) |  | kill(-(pg), (sig))

Referenced by rb_f_kill().

#define ruby_enable_coredump 0

Definition at line 1093 of file signal.c.

#define ruby_signal | ( |  | sig,
|  |  | handler
| ) |  | (/* rb_trap_accept_nativethreads[(sig)] = 0,*/ signal((sig),(handler)))

Definition at line 534 of file signal.c.

Referenced by install_sighandler(), ruby_sig_finalize(), sighandler(), and trap().

#define SIGINFO_ARG

Definition at line 446 of file signal.c.

## Typedef Documentation

typedef RETSIGTYPE ruby_sigaction_t(int)

Definition at line 445 of file signal.c.

typedef RETSIGTYPE(* sighandler_t)(int)

Definition at line 440 of file signal.c.

## Function Documentation

static sighandler_t default_handler | ( | int | sig | ) |
| static

Definition at line 754 of file signal.c.

References func, sighandler(), and SIGINT.

Referenced by trap_handler().

static VALUE esignal_init | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 252 of file signal.c.

References INT2NUM, NIL_P(), NSIG, NUM2INT, Qnil, rb_call_super(), rb_check_arity, rb_check_to_integer(), rb_eArgError, rb_id2name(), rb_iv_set(), rb_raise(), rb_sprintf(), signals::signm, signm2signo(), signals::signo, signo2signm(), StringValuePtr, SYM2ID, and SYMBOL_P.

Referenced by Init_signal().

static VALUE esignal_signo | ( | VALUE | self | ) |
| static

Definition at line 306 of file signal.c.

References rb_iv_get().

Referenced by Init_signal().

void Init_signal | ( | void |  | ) |

Definition at line 1134 of file signal.c.

References esignal_init(), esignal_signo(), GET_THREAD(), install_sighandler(), interrupt_init(), rb_alias(), rb_define_global_function(), rb_define_method(), rb_define_module(), rb_define_module_function(), rb_eInterrupt, rb_eSignal, rb_intern, sig_list(), sig_signame(), sig_trap(), sighandler(), and SIGINT.

static void install_sighandler | ( | int | signum,
|  | sighandler_t | handler
| ) |  |
| static

Definition at line 1048 of file signal.c.

References rb_disable_interrupt(), rb_enable_interrupt(), and ruby_signal.

Referenced by Init_signal().

static VALUE interrupt_init | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 313 of file signal.c.

References args, INT2FIX, rb_call_super(), rb_scan_args(), and SIGINT.

Referenced by Init_signal().

static void rb_disable_interrupt | ( | void |  | ) |
| static

Definition at line 570 of file signal.c.

References NULL, and pthread_sigmask().

Referenced by install_sighandler().

static void rb_enable_interrupt | ( | void |  | ) |
| static

Definition at line 580 of file signal.c.

References NULL, and pthread_sigmask().

Referenced by install_sighandler().

VALUE rb_f_kill | ( | int | argc,
|  | VALUE * | argv
| ) |  |

Definition at line 364 of file signal.c.

References argc, FIX2INT, i, INT2FIX, kill(), killpg, NIL_P(), NUM2PIDT, rb_check_arity, rb_check_string_type(), rb_eArgError, rb_id2name(), rb_obj_classname(), rb_raise(), rb_secure(), rb_sys_fail(), RSTRING_PTR, s, signm2signo(), str, SYM2ID, T_FIXNUM, T_STRING, T_SYMBOL, TYPE, and UNLIMITED_ARGUMENTS.

Referenced by Init_process().

int rb_get_next_signal | ( | void |  | ) |

Definition at line 590 of file signal.c.

References ATOMIC_DEC, i, RUBY_NSIG, and signal_buff.

Referenced by rb_threadptr_execute_interrupts().

int rb_signal_buff_size | ( | void |  | ) |

Definition at line 560 of file signal.c.

References signal_buff.

Referenced by rb_thread_check_trap_pending(), and rb_threadptr_check_signal().

void rb_signal_exec | ( | rb_thread_t * | th,
|  | int | sig
| ) |  |

Definition at line 712 of file signal.c.

References cmd, rb_vm_struct::cmd, GET_VM, Qundef, rb_interrupt(), rb_threadptr_signal_exit(), rb_threadptr_signal_raise(), rb_vm_struct::safe, safe, SIGINT, signal_exec(), and rb_vm_struct::trap_list.

Referenced by rb_threadptr_execute_interrupts().

void rb_trap_exit | ( | void |  | ) |

Definition at line 700 of file signal.c.

References rb_vm_struct::cmd, GET_VM, rb_vm_struct::safe, signal_exec(), and rb_vm_struct::trap_list.

Referenced by ruby_finalize_0().

static int reserved_signal_p | ( | int | signo | ) |
| static

Definition at line 931 of file signal.c.

Referenced by sig_trap().

rb_atomic_t ruby_atomic_compare_and_swap | ( | rb_atomic_t * | ptr,
|  | rb_atomic_t | cmp,
|  | rb_atomic_t | newval
| ) |  |

Definition at line 36 of file signal.c.

References ptr.

rb_atomic_t ruby_atomic_exchange | ( | rb_atomic_t * | ptr,
|  | rb_atomic_t | val
| ) |  |

Definition at line 28 of file signal.c.

References ptr, and val.

void ruby_default_signal | ( | int | sig | ) |

Definition at line 323 of file signal.c.

References signal().

Referenced by ruby_cleanup().

const char* ruby_signal_name | ( | int | no | ) |

Definition at line 237 of file signal.c.

References signo2signm().

Referenced by pst_message().

static VALUE sig_list | ( | void |  | ) |
| static

Definition at line 1036 of file signal.c.

References INT2FIX, rb_hash_aset(), rb_hash_new(), rb_str_new2, siglist, signals::signm, and signals::signo.

Referenced by Init_signal().

static VALUE sig_signame | ( | VALUE | recv,
|  | VALUE | signo
| ) |  |
| static

Definition at line 230 of file signal.c.

References NUM2INT, rb_str_new_cstr(), and signo2signm().

Referenced by Init_signal().

static VALUE sig_trap | ( | int | argc,
|  | VALUE * | argv
| ) |  |
| static

Definition at line 992 of file signal.c.

References cmd, func, name, OBJ_TAINTED, rb_block_proc(), rb_check_arity, rb_eArgError, rb_eSecurityError, rb_raise(), rb_secure(), reserved_signal_p(), sighandler(), signo2signm(), trap(), trap_handler(), and trap_signm().

Referenced by Init_signal().

static RETSIGTYPE sighandler | ( | int | sig | ) |
| static

Definition at line 549 of file signal.c.

References ATOMIC_INC, rb_thread_wakeup_timer_thread(), ruby_signal, and signal_buff.

Referenced by default_handler(), Init_signal(), ruby_sig_finalize(), sig_trap(), trap(), and trap_handler().

static void signal_exec | ( | VALUE | cmd,
|  | int | safe,
|  | int | sig
| ) |  |
| static

Definition at line 677 of file signal.c.

References EXEC_TAG, GET_THREAD(), INT2NUM, rb_thread_struct::interrupt_mask, JUMP_TAG, rb_ary_new3(), rb_eval_cmd(), state, TH_POP_TAG, TH_PUSH_TAG, and TRAP_INTERRUPT_MASK.

Referenced by rb_signal_exec(), and rb_trap_exit().

static int signm2signo | ( | const char * | nm | ) |
| static

Definition at line 195 of file signal.c.

References siglist, signals::signm, and signals::signo.

Referenced by esignal_init(), rb_f_kill(), and trap_signm().

static const char* signo2signm | ( | int | no | ) |
| static

Definition at line 206 of file signal.c.

References siglist, signals::signm, and signals::signo.

Referenced by esignal_init(), ruby_signal_name(), sig_signame(), and sig_trap().

static VALUE trap | ( | int | sig,
|  | sighandler_t | func,
|  | VALUE | command
| ) |  |
| static

Definition at line 900 of file signal.c.

References rb_vm_struct::cmd, GET_VM, Qnil, Qundef, rb_safe_level, rb_str_new2, ruby_signal, rb_vm_struct::safe, sighandler(), and rb_vm_struct::trap_list.

Referenced by sig_trap().

static sighandler_t trap_handler | ( | VALUE * | cmd,
|  | int | sig
| ) |  |
| static

Definition at line 803 of file signal.c.

References default_handler(), func, GetProcPtr, NIL_P(), proc, Qundef, rb_check_string_type(), rb_eArgError, rb_id2str(), rb_raise(), RSTRING_LEN, RSTRING_PTR, SafeStringValue, sighandler(), SYM2ID, SYMBOL_P, and void.

Referenced by sig_trap().

static int trap_signm | ( | VALUE | vsig | ) |
| static

Definition at line 868 of file signal.c.

References FIX2INT, NSIG, rb_eArgError, rb_id2name(), rb_raise(), s, signm2signo(), StringValuePtr, SYM2ID, T_FIXNUM, T_SYMBOL, and TYPE.

Referenced by sig_trap().

## Variable Documentation

rb_atomic_t cnt[RUBY_NSIG]

Definition at line 432 of file signal.c.

int ruby_enable_coredump = 0

Definition at line 1091 of file signal.c.

Referenced by set_debug_option().

struct signals siglist[]
| static

Referenced by sig_list(), signm2signo(), and signo2signm().

struct { ... } signal_buff

Referenced by rb_get_next_signal(), rb_signal_buff_size(), and sighandler().

rb_atomic_t size

Definition at line 433 of file signal.c.