Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
signal.c File Reference
`#include "internal.h"`
`#include "vm_core.h"`
`#include <signal.h>`
`#include <stdio.h>`
`#include <errno.h>`
`#include "ruby_atomic.h"`
`#include "eval_intern.h"`
`#include "debug_counter.h"`

Go to the source code of this file.

## Data Structures
struct | signals

## Macros
#define | VALGRIND_MAKE_MEM_DEFINED(p, n) 0
#define | VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#define | FOREACH_SIGNAL(sig, offset) for (sig = siglist + (offset); sig < siglist + numberof(siglist); ++sig)
#define | killpg(pg, sig) kill(-(pg), (sig))
#define | sighandler_t ruby_sighandler_t
#define | SIGINFO_ARG
#define | SIGINFO_CTX 0
#define | ruby_signal(sig, handler) (/* rb_trap_accept_nativethreads[(sig)] = 0,*/ signal((sig),(handler)))
#define | GET_SIGCHLD_HIT() 0
#define | clear_received_signal() ((void)0)
#define | CHECK_STACK_OVERFLOW() (void)0
#define | MESSAGE_FAULT_ADDRESS
#define | INSTALL_SIGHANDLER(cond, signame, signum)
#define | install_sighandler(signum, handler) INSTALL_SIGHANDLER(install_sighandler_core(signum, handler, NULL), #signum, signum)
#define | force_install_sighandler(signum, handler, old_handler) INSTALL_SIGHANDLER(install_sighandler_core(signum, handler, old_handler), #signum, signum)
#define | grantpt(fd) fake_grantfd(fd)

## Typedefs
typedef RETSIGTYPE | ruby_sigaction_t(int)

## Enumerations
enum | { LONGEST_SIGNAME = 7 }

## 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)
const char * | ruby_signal_name (int no)
void | rb_malloc_info_show_results (void)
void | ruby_default_signal (int sig)
VALUE | rb_f_kill (int argc, const VALUE *argv)
int | rb_signal_buff_size (void)
int | rb_get_next_signal (void)
void | rb_vm_trap_exit (rb_vm_t *vm)
void | ruby_waitpid_all (rb_vm_t *)
void | ruby_sigchld_handler (rb_vm_t *vm)
int | rb_signal_exec (rb_thread_t *th, int sig)
void | ruby_sig_finalize (void)
void | Init_signal (void)
int | rb_grantpt (int masterfd)

## Variables
int | ruby_enable_coredump = 0

## Macro Definition Documentation

## ◆ CHECK_STACK_OVERFLOW

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

Definition at line 902 of file signal.c.

## ◆ clear_received_signal

#define clear_received_signal | ( |  | ) | ((void)0)

Definition at line 777 of file signal.c.

## ◆ force_install_sighandler

#define force_install_sighandler | ( |  | signum,
|  |  | handler,
|  |  | old_handler
| ) |  | INSTALL_SIGHANDLER(install_sighandler_core(signum, handler, old_handler), #signum, signum)

Definition at line 1447 of file signal.c.

## ◆ FOREACH_SIGNAL

#define FOREACH_SIGNAL | ( |  | sig,
|  |  | offset
| ) |  | for (sig = siglist + (offset); sig < siglist + numberof(siglist); ++sig)

Definition at line 65 of file signal.c.

## ◆ GET_SIGCHLD_HIT

#define GET_SIGCHLD_HIT | ( |  | ) | 0

Definition at line 694 of file signal.c.

## ◆ grantpt

#define grantpt | ( |  | fd | ) | fake_grantfd(fd)

Definition at line 1593 of file signal.c.

## ◆ INSTALL_SIGHANDLER

#define INSTALL_SIGHANDLER | ( |  | cond,
|  |  | signame,
|  |  | signum
| ) |  |

Value:
do { \
static const char failed[] = "failed to install "signame" handler"; \
if (!(cond)) break; \
if (reserved_signal_p(signum)) rb_bug(failed); \
perror(failed); \
} while (0)

Definition at line 1420 of file signal.c.

## ◆ install_sighandler

#define install_sighandler | ( |  | signum,
|  |  | handler
| ) |  | INSTALL_SIGHANDLER(install_sighandler_core(signum, handler, NULL), #signum, signum)

Definition at line 1445 of file signal.c.

## ◆ killpg

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

## ◆ MESSAGE_FAULT_ADDRESS

#define MESSAGE_FAULT_ADDRESS

Definition at line 905 of file signal.c.

## ◆ ruby_signal

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

Definition at line 650 of file signal.c.

## ◆ sighandler_t

#define sighandler_t ruby_sighandler_t

Definition at line 510 of file signal.c.

## ◆ SIGINFO_ARG

#define SIGINFO_ARG

Definition at line 518 of file signal.c.

## ◆ SIGINFO_CTX

#define SIGINFO_CTX 0

Definition at line 519 of file signal.c.

## ◆ VALGRIND_MAKE_MEM_DEFINED

#define VALGRIND_MAKE_MEM_DEFINED | ( |  | p,
|  |  | n
| ) |  | 0

Definition at line 40 of file signal.c.

## ◆ VALGRIND_MAKE_MEM_UNDEFINED

#define VALGRIND_MAKE_MEM_UNDEFINED | ( |  | p,
|  |  | n
| ) |  | 0

Definition at line 41 of file signal.c.

## Typedef Documentation

## ◆ ruby_sigaction_t

typedef RETSIGTYPE ruby_sigaction_t(int)

Definition at line 517 of file signal.c.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
LONGEST_SIGNAME |

Definition at line 67 of file signal.c.

## Function Documentation

## ◆ Init_signal()

void Init_signal | ( | void |  | ) |

Definition at line 1521 of file signal.c.

References rb_define_global_function(), and rb_define_module().

## ◆ rb_f_kill()

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

Definition at line 418 of file signal.c.

References argc, argv, FIX2INT, FIXNUM_P, i, rb_check_arity, sig, str, and UNLIMITED_ARGUMENTS.

## ◆ rb_get_next_signal()

int rb_get_next_signal | ( | void |  | ) |

Definition at line 756 of file signal.c.

References i, and sig.

## ◆ rb_grantpt()

int rb_grantpt | ( | int | masterfd | ) |

Definition at line 1597 of file signal.c.

References errno, GET_VM, grantpt, rb_nativethread_lock_lock(), rb_nativethread_lock_unlock(), RUBY_SIGCHLD, and rb_vm_struct::waitpid_lock.

## ◆ rb_malloc_info_show_results()

void rb_malloc_info_show_results | ( | void |  | ) |

Definition at line 9979 of file gc.c.

Referenced by ruby_default_signal().

## ◆ rb_signal_buff_size()

int rb_signal_buff_size | ( | void |  | ) |

Definition at line 726 of file signal.c.

Referenced by rb_thread_check_trap_pending(), and rb_threadptr_check_signal().

## ◆ rb_signal_exec()

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

Definition at line 1082 of file signal.c.

References rb_vm_struct::cmd, GET_VM, Qundef, rb_interrupt(), rb_threadptr_signal_exit(), rb_threadptr_signal_raise(), sig, SIGALRM, SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2, and rb_vm_struct::trap_list.

## ◆ rb_vm_trap_exit()

void rb_vm_trap_exit | ( | rb_vm_t * | vm | ) |

Definition at line 1060 of file signal.c.

References rb_vm_struct::cmd, and rb_vm_struct::trap_list.

## ◆ ruby_atomic_compare_and_swap()

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

Definition at line 54 of file signal.c.

## ◆ ruby_atomic_exchange()

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

Definition at line 46 of file signal.c.

References old, and ptr.

## ◆ ruby_default_signal()

void ruby_default_signal | ( | int | sig | ) |

Definition at line 402 of file signal.c.

References rb_debug_counter_show_results(), rb_malloc_info_show_results(), sig, SIG_DFL, and signal().

## ◆ ruby_sigchld_handler()

void ruby_sigchld_handler | ( | rb_vm_t * | vm | ) |

Definition at line 1073 of file signal.c.

References GET_SIGCHLD_HIT, ruby_waitpid_all(), and SIGCHLD_LOSSY.

## ◆ ruby_signal_name()

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

Definition at line 310 of file signal.c.

## ◆ ruby_waitpid_all()

void ruby_waitpid_all | ( | rb_vm_t * |  | ) |

Definition at line 1029 of file process.c.

References list_empty, rb_native_mutex_lock(), ruby_nocldwait, rb_vm_struct::waiting_grps, rb_vm_struct::waiting_pids, and rb_vm_struct::waitpid_lock.

Referenced by ruby_sigchld_handler().

## Variable Documentation

## ◆ cnt

rb_atomic_t cnt[RUBY_NSIG]

Definition at line 503 of file signal.c.

Referenced by procstat_vm(), rb_alloc_tmp_buffer(), rb_ary_rotate(), rb_parser_calloc(), rb_parser_malloc(), and rb_parser_realloc().

## ◆ ruby_enable_coredump

int ruby_enable_coredump = 0

Definition at line 1481 of file signal.c.

Referenced by ruby_env_debug_option().

## ◆ size

rb_atomic_t size

Definition at line 504 of file signal.c.

rb_bug
void rb_bug(const char *fmt,...)
Definition: error.c:634