6
$Date: 2007-05-30 02:13:05 +0900 (水, 30 5月 2007) $
6
$Date: 2007-08-25 12:29:39 +0900 (土, 25 8月 2007) $
7
7
created at: Tue Dec 20 10:13:44 JST 1994
9
Copyright (C) 1993-2003 Yukihiro Matsumoto
9
Copyright (C) 1993-2007 Yukihiro Matsumoto
10
10
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
11
11
Copyright (C) 2000 Information-technology Promotion Agency, Japan
13
13
**********************************************************************/
15
#include "ruby/ruby.h"
16
#include "ruby/signal.h"
17
#include "ruby/node.h"
19
19
#include <signal.h>
550
552
VALUE signum = INT2FIX(sig);
551
553
GetProcPtr(cmd, proc);
552
th_invoke_proc(GET_THREAD(), proc, proc->block.self, 1, &signum);
554
vm_invoke_proc(GET_THREAD(), proc, proc->block.self, 1, &signum);
649
705
SafeStringValue(command); /* taint check */
650
706
switch (RSTRING_LEN(command)) {
711
if (strncmp(RSTRING_PTR(command), "SYSTEM_DEFAULT", 14) == 0) {
655
717
if (strncmp(RSTRING_PTR(command), "SIG_IGN", 7) == 0) {
658
722
else if (strncmp(RSTRING_PTR(command), "SIG_DFL", 7) == 0) {
724
func = default_handler(sig);
661
727
else if (strncmp(RSTRING_PTR(command), "DEFAULT", 7) == 0) {
666
732
if (strncmp(RSTRING_PTR(command), "IGNORE", 6) == 0) {
840
* Signal.trap( signal, proc ) => obj
856
* Signal.trap( signal, command ) => obj
841
857
* Signal.trap( signal ) {| | block } => obj
843
859
* Specifies the handling of signals. The first parameter is a signal
844
860
* name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a
845
861
* signal number. The characters ``SIG'' may be omitted from the
846
862
* signal name. The command or block specifies code to be run when the
847
* signal is raised. If the command is the string ``IGNORE'' or
848
* ``SIG_IGN'', the signal will be ignored. If the command is
849
* ``DEFAULT'' or ``SIG_DFL'', the operating system's default handler
850
* will be invoked. If the command is ``EXIT'', the script will be
851
* terminated by the signal. Otherwise, the given command or block
864
* If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal
866
* If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler
868
* If the command is ``EXIT'', the script will be terminated by the signal.
869
* If the command is ``SYSTEM_DEFAULT'', the operating system's default
870
* handler will be invoked.
871
* Otherwise, the given command or block will be run.
853
872
* The special signal name ``EXIT'' or signal number zero will be
854
873
* invoked just prior to program termination.
855
874
* trap returns the previous handler for the given signal.
1046
1069
install_sighandler(SIGUSR2, sighandler);
1072
#ifdef RUBY_DEBUG_ENV
1073
if (!ruby_enable_coredump)
1050
1077
install_sighandler(SIGBUS, sigbus);
1053
1080
install_sighandler(SIGSEGV, sigsegv);
1056
1084
install_sighandler(SIGPIPE, sigpipe);