Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Defines | 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 dependency graph for signal.c:

Go to the source code of this file.

## Data Structures
struct | signals
struct | trap_arg
## Defines
#define | ATOMIC_TEST(var) ((var) ? ((var) = 0, 1) : 0)
#define | ATOMIC_SET(var, val) ((var) = (val))
#define | ATOMIC_INC(var) (++(var))
#define | ATOMIC_DEC(var) (--(var))
#define | USE_TRAP_MASK 0
#define | killpg(pg, sig) kill(-(pg), sig)
#define | SIGINFO_ARG
#define | ruby_signal(sig, handler) (/* rb_trap_accept_nativethreads[sig] = 0,*/ signal((sig),(handler)))
## Typedefs
typedef int | rb_atomic_t
typedef RETSIGTYPE(* | sighandler_t )(int)
typedef RETSIGTYPE | ruby_sigaction_t (int)
## Functions
static int | signm2signo (const char *nm)
static const char * | signo2signm (int no)
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)
void | rb_disable_interrupt (void)
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 (struct trap_arg *arg)
void | rb_trap_restore_mask (void)
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

## Define Documentation

#define ATOMIC_DEC | ( |  | var | ) | (--(var))

Definition at line 34 of file signal.c.

Referenced by rb_get_next_signal().

#define ATOMIC_INC | ( |  | var | ) | (++(var))

Definition at line 33 of file signal.c.

Referenced by sighandler().

#define ATOMIC_SET | ( |  | var,
|  |  | val
| ) |  | ((var) = (val))

Definition at line 32 of file signal.c.

#define ATOMIC_TEST | ( |  | var | ) | ((var) ? ((var) = 0, 1) : 0)

Definition at line 31 of file signal.c.

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

Referenced by rb_f_kill().

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

Definition at line 500 of file signal.c.

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

#define SIGINFO_ARG

Definition at line 429 of file signal.c.

#define USE_TRAP_MASK 0

Definition at line 44 of file signal.c.

## Typedef Documentation

typedef int rb_atomic_t

Definition at line 29 of file signal.c.

typedef RETSIGTYPE ruby_sigaction_t(int)

Definition at line 428 of file signal.c.

typedef RETSIGTYPE(* sighandler_t)(int)

Definition at line 423 of file signal.c.

## Function Documentation

static sighandler_t default_handler | ( | int | sig | ) | `[static]`

Definition at line 701 of file signal.c.

References func, GET_THREAD, sighandler(), and SIGINT.

Referenced by trap_handler().

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

Definition at line 228 of file signal.c.

References INT2NUM(), NIL_P, NSIG, NUM2INT, Qnil, rb_call_super(), 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 285 of file signal.c.

References rb_iv_get().

Referenced by Init_signal().

void Init_signal | ( | void |  | ) |

Definition at line 1086 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_trap(), sighandler(), and SIGINT.

static void install_sighandler | ( | int | signum,
|  | sighandler_t | handler
| ) |  | `[static]`

Definition at line 988 of file signal.c.

References ruby_signal.

Referenced by Init_signal().

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

Definition at line 292 of file signal.c.

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

Referenced by Init_signal().

void rb_disable_interrupt | ( | void |  | ) |

Definition at line 543 of file signal.c.

References NULL, and pthread_sigmask().

Referenced by rb_get_next_signal().

void rb_enable_interrupt | ( | void |  | ) |

Definition at line 555 of file signal.c.

References NULL, and pthread_sigmask().

Referenced by rb_get_next_signal().

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

Definition at line 343 of file signal.c.

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

Referenced by Init_process().

int rb_get_next_signal | ( | void |  | ) |

Definition at line 565 of file signal.c.

References ATOMIC_DEC, rb_disable_interrupt(), rb_enable_interrupt(), RUBY_NSIG, and signal_buff.

Referenced by rb_threadptr_check_signal().

int rb_signal_buff_size | ( | void |  | ) |

Definition at line 525 of file signal.c.

References signal_buff.

Referenced by rb_threadptr_execute_interrupts_rec().

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

Definition at line 646 of file signal.c.

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

Referenced by rb_threadptr_execute_interrupts_rec().

void rb_trap_exit | ( | void |  | ) |

Definition at line 634 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().

void rb_trap_restore_mask | ( | void |  | ) |

Definition at line 894 of file signal.c.

References NULL, and pthread_sigmask().

Referenced by rb_throw_obj(), and setup_exception().

void ruby_default_signal | ( | int | sig | ) |

Definition at line 302 of file signal.c.

References signal().

Referenced by ruby_cleanup().

void ruby_sig_finalize | ( | void |  | ) |

Definition at line 1033 of file signal.c.

References ruby_signal, sighandler(), and SIGINT.

Referenced by ruby_finalize_1().

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

Definition at line 213 of file signal.c.

References signo2signm().

Referenced by pst_message().

static VALUE sig_list | ( | void |  | ) | `[static]`

Definition at line 976 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_trap | ( | int | argc,
|  | VALUE * | argv
| ) |  | `[static]`

Definition at line 933 of file signal.c.

References trap_arg::cmd, trap_arg::func, OBJ_TAINTED, pthread_sigmask(), rb_block_proc(), rb_eArgError, rb_ensure(), rb_eSecurityError, rb_raise(), rb_secure(), trap_arg::sig, sighandler(), trap(), trap_handler(), and trap_signm().

Referenced by Init_signal().

static RETSIGTYPE sighandler | ( | int | sig | ) | `[static]`

Definition at line 515 of file signal.c.

References ATOMIC_INC, 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 627 of file signal.c.

References INT2NUM(), rb_ary_new3(), and rb_eval_cmd().

Referenced by rb_signal_exec(), and rb_trap_exit().

static int signm2signo | ( | const char * | nm | ) | `[static]`

Definition at line 191 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 202 of file signal.c.

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

Referenced by esignal_init(), and ruby_signal_name().

static VALUE trap | ( | struct trap_arg * | arg | ) | `[static]`

Definition at line 849 of file signal.c.

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

Referenced by sig_trap().

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

Definition at line 753 of file signal.c.

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

Referenced by sig_trap().

static int trap_signm | ( | VALUE | vsig | ) | `[static]`

Definition at line 817 of file signal.c.

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

Referenced by sig_trap().

## Variable Documentation

rb_atomic_t cnt[RUBY_NSIG]

Definition at line 415 of file signal.c.

Referenced by compile_dregx(), compile_dstr(), compile_dstr_fragments(), ip_init(), local_tbl_gen(), rb_ary_rotate_m(), rb_parser_calloc(), rb_parser_malloc(), rb_parser_realloc(), swallow(), and vtable_tblcpy().

struct signals siglist[]`[static]`

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

struct { ... } signal_buff`[static]`

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

rb_atomic_t size

Definition at line 416 of file signal.c.