From: matz@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:82578] [Ruby trunk Feature#13639] Add "RTMIN" and "RTMAX" to Signal.list
Date: Thu, 31 Aug 2017 09:06:39 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-66399.20170831090638.4e3a0a0826960c73@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13639.20170608052229@ruby-lang.org
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/
prev parent reply other threads:[~2017-08-31 9:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-66399.20170831090638.4e3a0a0826960c73@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).