librelist archives

« back to archive

dropping signalfd() support

dropping signalfd() support

From:
Eric Wong
Date:
2011-05-15 @ 01:09
I don't think it has a chance of playing nicely/reliably with built-in
Ruby signal handling + threads.

Unlike C, Ruby itself has a great API for dealing with signals so I don't
think an equivalent signalfd() interface is necessary.

Expect this to be dropped in the next release.

-- 
Eric Wong

Re: [sleepy.penguin] dropping signalfd() support

From:
Eric Wong
Date:
2011-05-19 @ 23:45
Eric Wong <normalperson@yhbt.net> wrote:
> Expect this to be dropped in the next release.

I'll just keep it in case somebody wants to have fun with it, but it's
not recommended and now documented as so in sleepy_penguin.git

-- 
Eric Wong

Re: [sleepy.penguin] dropping signalfd() support

From:
Eric Wong
Date:
2011-07-27 @ 00:23
Eric Wong <normalperson@yhbt.net> wrote:
> Eric Wong <normalperson@yhbt.net> wrote:
> > Expect this to be dropped in the next release.
> 
> I'll just keep it in case somebody wants to have fun with it, but it's
> not recommended and now documented as so in sleepy_penguin.git

Code is still there and trivial to re-enable by editing extconf.rb,
but I've disabled it:

From c77c7e4cf7f2850d7163db3fcbed5a0ef829edb9 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson@yhbt.net>
Date: Tue, 26 Jul 2011 17:11:43 -0700
Subject: [PATCH] disable SignalFD interface

It's a waste of memory to have something that has no chance
of working reliably with any existing Ruby runtimes.
---
 README                        |    2 +-
 ext/sleepy_penguin/epoll.c    |    3 +--
 ext/sleepy_penguin/extconf.rb |    7 +++++--
 ext/sleepy_penguin/signalfd.c |    5 ++++-
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/README b/README
index e26b2c6..c32840f 100644
--- a/README
+++ b/README
@@ -2,7 +2,7 @@
 
 sleepy_penguin provides access to newer, Linux-only system calls to wait
 on events from traditionally non-I/O sources.  Bindings to the eventfd,
-timerfd, inotify, signalfd and epoll interfaces are provided.
+timerfd, inotify, and epoll interfaces are provided.
 
 == Features
 
diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c
index 54edc87..fd23594 100644
--- a/ext/sleepy_penguin/epoll.c
+++ b/ext/sleepy_penguin/epoll.c
@@ -733,7 +733,7 @@ void sleepy_penguin_init_epoll(void)
 	 *	require "sleepy_penguin"
 	 *	include SleepyPenguin
 	 *
-	 * The SleepyPenguin namespace includes the Epoll, Inotify, SignalFD,
+	 * The SleepyPenguin namespace includes the Epoll, Inotify,
 	 * TimerFD, EventFD classes in its top level and no other constants.
 	 *
 	 * If you are uncomfortable including SleepyPenguin, you may also
@@ -746,7 +746,6 @@ void sleepy_penguin_init_epoll(void)
 	 * - SP::Epoll
 	 * - SP::EventFD
 	 * - SP::Inotify
-	 * - SP::SignalFD
 	 * - SP::TimerFD
 	 */
 	mSleepyPenguin = rb_define_module("SleepyPenguin");
diff --git a/ext/sleepy_penguin/extconf.rb b/ext/sleepy_penguin/extconf.rb
index 724309a..fe8e1ac 100644
--- a/ext/sleepy_penguin/extconf.rb
+++ b/ext/sleepy_penguin/extconf.rb
@@ -2,10 +2,13 @@ require 'mkmf'
 have_header('sys/epoll.h') or abort 'sys/epoll.h not found'
 have_header("pthread.h") or abort 'pthread.h not found'
 have_header('sys/eventfd.h')
-have_header('sys/signalfd.h')
+
+# it's impossible to use signalfd reliably with Ruby since Ruby currently
+# manages # (and overrides) all signal handling
+# have_header('sys/signalfd.h')
+
 have_header('sys/timerfd.h')
 have_header('sys/inotify.h')
-have_header('sys/signalfd.h')
 have_header('ruby/io.h') and have_struct_member('rb_io_t', 'fd', 'ruby/io.h')
 have_func('epoll_create1', %w(sys/epoll.h))
 have_func('rb_thread_blocking_region')
diff --git a/ext/sleepy_penguin/signalfd.c b/ext/sleepy_penguin/signalfd.c
index b837359..59eb05f 100644
--- a/ext/sleepy_penguin/signalfd.c
+++ b/ext/sleepy_penguin/signalfd.c
@@ -242,6 +242,9 @@ void sleepy_penguin_init_signalfd(void)
 	 * Use of this class is NOT recommended.  Ruby itself has a great
 	 * signal handling API and its implementation conflicts with this.
 	 *
+	 * This class is currently disabled and the documentation is only
+	 * provided to describe what it would look like.
+	 *
 	 * A SignalFD is an IO object for accepting signals.  It provides
 	 * an alternative to Signal.trap that may be monitored using
 	 * IO.select or Epoll.
@@ -251,7 +254,7 @@ void sleepy_penguin_init_signalfd(void)
 	 * decent signal handling interface anyways, this class is less useful
 	 * than signalfd() in a C-only environment.
 	 *
-	 * It is not supported at all under (Matz) Ruby 1.8.
+	 * It is not supported at all.
 	 */
 	cSignalFD = rb_define_class_under(mSleepyPenguin, "SignalFD", rb_cIO);
 
-- 
Eric Wong