Ruby: signal.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
signal.c File Reference
`#include "ruby/internal/config.h"`
`#include <errno.h>`
`#include <signal.h>`
`#include <stdio.h>`
`#include "debug_counter.h"`
`#include "eval_intern.h"`
`#include "internal.h"`
`#include "internal/eval.h"`
`#include "internal/sanitizers.h"`
`#include "internal/signal.h"`
`#include "internal/string.h"`
`#include "internal/thread.h"`
`#include "ruby_atomic.h"`
`#include "vm_core.h"`
`#include "ractor_core.h"`

Go to the source code of this file.

## Data Structures
struct | signals

## Macros
#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 void | ruby_sigaction_t(int)

## Enumerations
enum | { LONGEST_SIGNAME = 7 }

## Functions
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 919 of file signal.c.

## ◆ clear_received_signal

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

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

## ◆ FOREACH_SIGNAL

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

Definition at line 69 of file signal.c.

## ◆ GET_SIGCHLD_HIT

#define GET_SIGCHLD_HIT | ( |  | ) | 0

Definition at line 715 of file signal.c.

## ◆ grantpt

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

Definition at line 1619 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)
rb_bug
void rb_bug(const char *fmt,...)
Definition: error.c:768

Definition at line 1446 of file signal.c.

## ◆ install_sighandler

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

Definition at line 1471 of file signal.c.

## ◆ killpg

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

## ◆ MESSAGE_FAULT_ADDRESS

#define MESSAGE_FAULT_ADDRESS

Definition at line 922 of file signal.c.

## ◆ ruby_signal

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

Definition at line 671 of file signal.c.

## ◆ sighandler_t

#define sighandler_t ruby_sighandler_t

Definition at line 515 of file signal.c.

## ◆ SIGINFO_ARG

#define SIGINFO_ARG

Definition at line 523 of file signal.c.

## ◆ SIGINFO_CTX

#define SIGINFO_CTX 0

Definition at line 524 of file signal.c.

## Typedef Documentation

## ◆ ruby_sigaction_t

typedef void ruby_sigaction_t(int)

Definition at line 522 of file signal.c.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
LONGEST_SIGNAME |

Definition at line 71 of file signal.c.

## Function Documentation

## ◆ Init_signal()

void Init_signal | ( | void |  | ) |

Definition at line 1547 of file signal.c.

References force_install_sighandler, install_sighandler, rb_alias(), RB_ALTSTACK_INIT, rb_define_global_function, rb_define_method, rb_define_module(), rb_define_module_function, rb_eInterrupt, rb_eSignal, ruby_enable_coredump, RUBY_SIGCHLD, sighandler_t, and SIGINT.

## ◆ rb_f_kill()

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

Definition at line 423 of file signal.c.

References argc, argv, FALSE, FIX2INT, FIXNUM_P, INT2FIX, kill(), killpg, NULL, NUM2PIDT, rb_check_arity, rb_sys_fail(), rb_thread_current(), rb_thread_execute_interrupts(), rb_threadptr_check_signal(), SIGKILL, str, t, TRUE, and UNLIMITED_ARGUMENTS.

## ◆ rb_get_next_signal()

int rb_get_next_signal | ( | void |  | ) |

Definition at line 773 of file signal.c.

References ATOMIC_DEC, and RUBY_NSIG.

Referenced by rb_threadptr_execute_interrupts().

## ◆ rb_grantpt()

int rb_grantpt | ( | int | masterfd | ) |

Definition at line 1623 of file signal.c.

References 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 10742 of file gc.c.

Referenced by ruby_default_signal().

## ◆ rb_signal_buff_size()

int rb_signal_buff_size | ( | void |  | ) |

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

References rb_vm_struct::cmd, FALSE, Qundef, rb_interrupt(), rb_threadptr_signal_exit(), rb_threadptr_signal_raise(), SIGINT, and rb_vm_struct::trap_list.

Referenced by rb_threadptr_execute_interrupts().

## ◆ rb_vm_trap_exit()

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

Definition at line 1077 of file signal.c.

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

## ◆ ruby_default_signal()

void ruby_default_signal | ( | int | sig | ) |

Definition at line 407 of file signal.c.

References rb_debug_counter_show_results(), and rb_malloc_info_show_results().

## ◆ ruby_sigchld_handler()

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

Definition at line 1090 of file signal.c.

References GET_SIGCHLD_HIT, ruby_waitpid_all(), and SIGCHLD_LOSSY.

Referenced by rb_threadptr_execute_interrupts().

## ◆ ruby_signal_name()

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

Definition at line 316 of file signal.c.

## ◆ ruby_waitpid_all()

void ruby_waitpid_all | ( | rb_vm_t * | vm | ) |

Definition at line 1156 of file process.c.

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

Referenced by ruby_sigchld_handler().

## Variable Documentation

## ◆ cnt

rb_atomic_t cnt[RUBY_NSIG]

Definition at line 508 of file signal.c.

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

## ◆ ruby_enable_coredump

int ruby_enable_coredump = 0

Definition at line 1507 of file signal.c.

Referenced by Init_signal(), and ruby_env_debug_option().

## ◆ size

rb_atomic_t size

Definition at line 509 of file signal.c.