From: Tanaka Akira Date: 2010-01-22T12:43:11+09:00 Subject: [ruby-core:27676] Re: [Bug #2619] Proposed method: Process.fork_supported? 2010/1/22 Vladimir Sizikov : > > I should probably also add that this is close to impossible to > implement on JRuby (and I assume on IronRuby too, and maybe some > others). In case of JRuby, we build once and then the resulting > product can be used on various platforms, so those platform specific > things are queried at runtime. In some cases we just invoke a native > functions via FFI at runtime and only then would see > NotImplementedError out of those calls. So, basically, untill the > method is executed, we can't really know whether it is supported or > not on some platforms. In general, I recommend programs call such methods simply and rescue NotImplementedError. This style should work with various Ruby including Ruby 1.8 and JRuby. However there are requests for testing the availability of the methods without calling them. It is reasonable if the methods have unavoidable side-effects. This respond_to? behavior is for such requests. If we take the reason "we can't really know whether it is supported or not on some platforms.", we cannot provide a solution for the above requests. However I know the reason is actually true even in C. For example, new Linux system call is provided by glibc but Ruby runs on older Linux, the system call causes ENOSYS. We can't really know the system call is supported or not on the running system. So I recommend "just call and rescue" if possible. -- Tanaka Akira