signal_action_handler 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: '097ae081c2e06474af33104de8353d855e9fb456'
4
+ data.tar.gz: 75e6a13eef5586d1f42a3e38fb8ba1c02c768b9a
5
+ SHA512:
6
+ metadata.gz: 2a833ec567a36592a24d063d9e77bd292c2cfa83a077b2098cafad7b095fd28380141994aa23cafa7c230907e8d5deb9808531db1e3b3f2446b6c6707cb3853a
7
+ data.tar.gz: 74c2d00000dcf36f7899a473c2fcfbddb71bc82933e46e233519086af68c0a20ee2e0237ffc41775e31fe49924912e518616f766f37a383395904116804ec403
@@ -0,0 +1,5 @@
1
+ require "mkmf"
2
+
3
+ abort "missing rb_hash_new()" unless have_func "rb_hash_new"
4
+
5
+ create_makefile "signal_action_handler/signal_action_handler"
@@ -0,0 +1,194 @@
1
+ #include "ruby.h"
2
+ #include <stdio.h>
3
+ #include <signal.h>
4
+
5
+ static const struct signals {
6
+ const char *signame;
7
+ int signum;
8
+ } siginfo [] = {
9
+ {"EXIT", 0},
10
+ #ifdef SIGHUP
11
+ {"HUP", SIGHUP},
12
+ #endif
13
+ {"INT", SIGINT},
14
+ #ifdef SIGQUIT
15
+ {"QUIT", SIGQUIT},
16
+ #endif
17
+ #ifdef SIGILL
18
+ {"ILL", SIGILL},
19
+ #endif
20
+ #ifdef SIGTRAP
21
+ {"TRAP", SIGTRAP},
22
+ #endif
23
+ #ifdef SIGABRT
24
+ {"ABRT", SIGABRT},
25
+ #endif
26
+ #ifdef SIGIOT
27
+ {"IOT", SIGIOT},
28
+ #endif
29
+ #ifdef SIGEMT
30
+ {"EMT", SIGEMT},
31
+ #endif
32
+ #ifdef SIGFPE
33
+ {"FPE", SIGFPE},
34
+ #endif
35
+ #ifdef SIGKILL
36
+ {"KILL", SIGKILL},
37
+ #endif
38
+ #ifdef SIGBUS
39
+ {"BUS", SIGBUS},
40
+ #endif
41
+ #ifdef SIGSEGV
42
+ {"SEGV", SIGSEGV},
43
+ #endif
44
+ #ifdef SIGSYS
45
+ {"SYS", SIGSYS},
46
+ #endif
47
+ #ifdef SIGPIPE
48
+ {"PIPE", SIGPIPE},
49
+ #endif
50
+ #ifdef SIGALRM
51
+ {"ALRM", SIGALRM},
52
+ #endif
53
+ #ifdef SIGTERM
54
+ {"TERM", SIGTERM},
55
+ #endif
56
+ #ifdef SIGURG
57
+ {"URG", SIGURG},
58
+ #endif
59
+ #ifdef SIGSTOP
60
+ {"STOP", SIGSTOP},
61
+ #endif
62
+ #ifdef SIGTSTP
63
+ {"TSTP", SIGTSTP},
64
+ #endif
65
+ #ifdef SIGCONT
66
+ {"CONT", SIGCONT},
67
+ #endif
68
+ #ifdef SIGCHLD
69
+ {"CHLD", SIGCHLD},
70
+ #endif
71
+ #ifdef SIGCLD
72
+ {"CLD", SIGCLD},
73
+ #else
74
+ # ifdef SIGCHLD
75
+ {"CLD", SIGCHLD},
76
+ # endif
77
+ #endif
78
+ #ifdef SIGTTIN
79
+ {"TTIN", SIGTTIN},
80
+ #endif
81
+ #ifdef SIGTTOU
82
+ {"TTOU", SIGTTOU},
83
+ #endif
84
+ #ifdef SIGIO
85
+ {"IO", SIGIO},
86
+ #endif
87
+ #ifdef SIGXCPU
88
+ {"XCPU", SIGXCPU},
89
+ #endif
90
+ #ifdef SIGXFSZ
91
+ {"XFSZ", SIGXFSZ},
92
+ #endif
93
+ #ifdef SIGVTALRM
94
+ {"VTALRM", SIGVTALRM},
95
+ #endif
96
+ #ifdef SIGPROF
97
+ {"PROF", SIGPROF},
98
+ #endif
99
+ #ifdef SIGWINCH
100
+ {"WINCH", SIGWINCH},
101
+ #endif
102
+ #ifdef SIGUSR1
103
+ {"USR1", SIGUSR1},
104
+ #endif
105
+ #ifdef SIGUSR2
106
+ {"USR2", SIGUSR2},
107
+ #endif
108
+ #ifdef SIGLOST
109
+ {"LOST", SIGLOST},
110
+ #endif
111
+ #ifdef SIGMSG
112
+ {"MSG", SIGMSG},
113
+ #endif
114
+ #ifdef SIGPWR
115
+ {"PWR", SIGPWR},
116
+ #endif
117
+ #ifdef SIGPOLL
118
+ {"POLL", SIGPOLL},
119
+ #endif
120
+ #ifdef SIGDANGER
121
+ {"DANGER", SIGDANGER},
122
+ #endif
123
+ #ifdef SIGMIGRATE
124
+ {"MIGRATE", SIGMIGRATE},
125
+ #endif
126
+ #ifdef SIGPRE
127
+ {"PRE", SIGPRE},
128
+ #endif
129
+ #ifdef SIGGRANT
130
+ {"GRANT", SIGGRANT},
131
+ #endif
132
+ #ifdef SIGRETRACT
133
+ {"RETRACT", SIGRETRACT},
134
+ #endif
135
+ #ifdef SIGSOUND
136
+ {"SOUND", SIGSOUND},
137
+ #endif
138
+ #ifdef SIGINFO
139
+ {"INFO", SIGINFO},
140
+ #endif
141
+ {NULL, 0}
142
+ };
143
+ const struct signals *sigs;
144
+
145
+ // Define space for module
146
+ VALUE SignalActionHandler = Qnil;
147
+
148
+ // init module, used by ruby not here
149
+ void Init_signal_action_handler();
150
+
151
+ // prototype method name "info"
152
+ VALUE method_info(VALUE self);
153
+
154
+ void Init_signal_action_handler()
155
+ {
156
+ SignalActionHandler = rb_define_class("SignalActionHandler", rb_cObject);
157
+ rb_define_singleton_method(SignalActionHandler, "info", method_info, 0);
158
+ }
159
+
160
+ // method name "info"
161
+ VALUE method_info(VALUE self)
162
+ {
163
+ VALUE h = rb_hash_new();
164
+ struct sigaction oldact;
165
+ const char *handler;
166
+
167
+ for (sigs = siginfo; sigs->signame; sigs++)
168
+ {
169
+ sigaction(sigs->signum, NULL, &oldact);
170
+ if (oldact.sa_handler == SIG_DFL)
171
+ {
172
+ handler = "SYSTEM_DEFAULT";
173
+ }
174
+ else if (oldact.sa_handler == SIG_IGN)
175
+ {
176
+ handler = "IGNORE";
177
+ }
178
+ else if (oldact.sa_handler == SIG_DFL)
179
+ {
180
+ handler = "SYSTEM_DEFAULT";
181
+ }
182
+ else if (oldact.sa_handler == SIG_DFL)
183
+ {
184
+ handler = "SYSTEM_DEFAULT";
185
+ }
186
+ else
187
+ {
188
+ handler = "DEFAULT";
189
+ }
190
+ rb_hash_aset(h, rb_str_new2(sigs->signame), rb_str_new2(handler));
191
+ }
192
+
193
+ return h;
194
+ }
@@ -0,0 +1 @@
1
+ require "signal_action_handler/signal_action_handler"
@@ -0,0 +1,3 @@
1
+ class SignalActionHandler
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: signal_action_handler
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Shayon Mukherjee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.4
69
+ description: List current action handlers for all Signals, without having to override
70
+ the current action handlers to retrieve the same information.
71
+ email:
72
+ - dev@shayon.me
73
+ executables: []
74
+ extensions:
75
+ - ext/signal_action_handler/extconf.rb
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ext/signal_action_handler/extconf.rb
79
+ - ext/signal_action_handler/signal_action_handler.c
80
+ - lib/signal_action_handler.rb
81
+ - lib/signal_action_handler/version.rb
82
+ homepage: https://github.com/shayonj/signal_action_handler
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 2.1.5
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.6.14
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: List the current action handlers for all Signals.
106
+ test_files: []