Ruby 3.5.0dev (2025-02-22 revision 412997300569c1853c09813e4924b6df3d7e8669)
|
Signal handling APIs. More...
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
Go to the source code of this file.
Functions | |
VALUE | rb_f_kill (int argc, const VALUE *argv) |
Sends a signal ("kills") to processes. | |
const char * | ruby_signal_name (int signo) |
Queries the name of the signal. | |
void | ruby_default_signal (int sig) |
Pretends as if there was no custom signal handler. | |
Signal handling APIs.
RBIMPL
or rbimpl
are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will. __VA_ARGS__
is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98. Definition in file signal.h.
Sends a signal ("kills") to processes.
The first argument is the signal, either in:
9
), or:SIGKILL
) name or abbreviated (e.g. :KILL
) name, either in rb_cSymbol or rb_cString.All the remaining arguments are numerical representations of process IDs. This function iterates over them to send the specified signal.
You can specify both negative PIDs and negative signo to this function:
Errno::ESRCH
is raised.Errno::ESRCH
is raised.killpg(3posix)
with an argument of zero) is an undefined behaviour. But no operating system is known so far that does things differently.killpg(3)
works. On Linux, it seems such attempt is strictly prohibited and Errno::EINVAL
is raised. But on macOS, it seems it tries to send the signal actually to the process group.kill(2)
works. We interpret the passed arguments before passing them through to system calls. [in] | argc | Number of objects in argv . |
[in] | argv | Signal, followed by target PIDs. |
rb_eArgError | Unknown signal name. |
rb_eSystemCallError | Various errors sending signal to processes. |
Definition at line 430 of file signal.c.
Referenced by rb_f_kill().
void ruby_default_signal | ( | int | sig | ) |
Pretends as if there was no custom signal handler.
This function sets the signal action to SIG_DFL, then kills itself.
[in] | sig | The signal. |
Definition at line 411 of file signal.c.
Referenced by ruby_default_signal().
const char * ruby_signal_name | ( | int | signo | ) |
Queries the name of the signal.
It returns for instance "KILL"
for SIGKILL.
[in] | signo | Signal number to query. |
0 | No such signal. |
otherwise | A pointer to a static C string that is the name of the signal. |
Definition at line 317 of file signal.c.
Referenced by ruby_signal_name().