ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:81617] [Ruby trunk Feature#13639] Add "RTMIN" and "RTMAX" to Signal.list
       [not found] <redmine.issue-13639.20170608052229@ruby-lang.org>
@ 2017-06-08  5:22 ` co000ri
  2017-08-31  9:06 ` [ruby-core:82578] " matz
  1 sibling, 0 replies; 2+ messages in thread
From: co000ri @ 2017-06-08  5:22 UTC (permalink / raw)
  To: ruby-core

Issue #13639 has been reported by ksss (Yuki Kurihara).

----------------------------------------
Feature #13639: Add "RTMIN" and "RTMAX" to Signal.list
https://bugs.ruby-lang.org/issues/13639

* Author: ksss (Yuki Kurihara)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I propose to add the key "RTMIN" and "RTMAX" to Signal.list

Currently, We can't know signal number for realtime-signal at own environment in Ruby.
And it's not potable if hard code number literal.

So, How about this idea?

Use case:

~~~ruby
unless Signal.list["RTMIN"]
  raise "realtime-signal does not supported"
end

MY_SIGNAL = Signal.list["RTMIN"] + 1

Signal.trap(MY_SIGNAL) do |i|
  puts "Hello MY_SIGNAL"
end

Process.kill(MY_SIGNAL, $$)
#=> "Hello MY_SIGNAL"
~~~

Patch:

~~~diff
diff --git a/signal.c b/signal.c
index 8ee0963b8a..f17836350a 100644
--- a/signal.c
+++ b/signal.c
@@ -1381,6 +1381,12 @@ sig_list(void)
     for (sigs = siglist; sigs->signm; sigs++) {
        rb_hash_aset(h, rb_fstring_cstr(sigs->signm), INT2FIX(sigs->signo));
     }
+#ifdef SIGRTMIN
+    rb_hash_aset(h, rb_fstring_cstr("RTMIN"), INT2FIX(SIGRTMIN));
+#endif
+#ifdef SIGRTMAX
+    rb_hash_aset(h, rb_fstring_cstr("RTMAX"), INT2FIX(SIGRTMAX));
+#endif
     return h;
 }
~~~

Inspired by https://github.com/ksss/mruby-signal/pull/3 and @takumakume



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [ruby-core:82578] [Ruby trunk Feature#13639] Add "RTMIN" and "RTMAX" to Signal.list
       [not found] <redmine.issue-13639.20170608052229@ruby-lang.org>
  2017-06-08  5:22 ` [ruby-core:81617] [Ruby trunk Feature#13639] Add "RTMIN" and "RTMAX" to Signal.list co000ri
@ 2017-08-31  9:06 ` matz
  1 sibling, 0 replies; 2+ messages in thread
From: matz @ 2017-08-31  9:06 UTC (permalink / raw)
  To: ruby-core

Issue #13639 has been updated by matz (Yukihiro Matsumoto).


I propose

* Signal::RTMIN
* Signal::RTMAX

instead.

Matz.


----------------------------------------
Feature #13639: Add "RTMIN" and "RTMAX" to Signal.list
https://bugs.ruby-lang.org/issues/13639#change-66399

* Author: ksss (Yuki Kurihara)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I propose to add the key "RTMIN" and "RTMAX" to Signal.list

Currently, We can't know signal number for realtime-signal at own environment in Ruby.
And it's not potable if hard code number literal.

So, How about this idea?

Use case:

~~~ruby
unless Signal.list["RTMIN"]
  raise "realtime-signal does not supported"
end

MY_SIGNAL = Signal.list["RTMIN"] + 1

Signal.trap(MY_SIGNAL) do |i|
  puts "Hello MY_SIGNAL"
end

Process.kill(MY_SIGNAL, $$)
#=> "Hello MY_SIGNAL"
~~~

Patch:

~~~diff
diff --git a/signal.c b/signal.c
index 8ee0963b8a..f17836350a 100644
--- a/signal.c
+++ b/signal.c
@@ -1381,6 +1381,12 @@ sig_list(void)
     for (sigs = siglist; sigs->signm; sigs++) {
        rb_hash_aset(h, rb_fstring_cstr(sigs->signm), INT2FIX(sigs->signo));
     }
+#ifdef SIGRTMIN
+    rb_hash_aset(h, rb_fstring_cstr("RTMIN"), INT2FIX(SIGRTMIN));
+#endif
+#ifdef SIGRTMAX
+    rb_hash_aset(h, rb_fstring_cstr("RTMAX"), INT2FIX(SIGRTMAX));
+#endif
     return h;
 }
~~~

Inspired by https://github.com/ksss/mruby-signal/pull/3 and @takumakume



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-31  9:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-13639.20170608052229@ruby-lang.org>
2017-06-08  5:22 ` [ruby-core:81617] [Ruby trunk Feature#13639] Add "RTMIN" and "RTMAX" to Signal.list co000ri
2017-08-31  9:06 ` [ruby-core:82578] " matz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).