Is it possible to determine whether the implementation of ruby you're running on is capable of supporting fork
, without running a regex against RUBY_PLATFORM
that'll expand until it summons Cthulhu?
(Related question: Ruby - How can I find out on which system my program is running?)
Edit: I tried Marc-Andre's suggestion. It doesn't work for jruby with fork disabled by default:
192-168-1-7:~ agrimm$ jruby --1.9 -S jirb
irb(main):001:0> RUBY_VERSION
=> "1.9.2dev"
irb(main):002:0> Process.respond_to?(:fork)
=> true
irb(main):003:0> Process.fork
NotImplementedError: fork is unsafe and disabled by default on JRuby
Update: From Marc-Andre's link, it seems wiser heads than I have grappled with this problem from the perspective of creating ruby implementations, and failed.
From the perspective of someone who's writing a ruby library, what would be the most comprehensive incantation, short of running fork and seeing if it raises an exception?