(2011/07/02 10:17), SASADA Koichi wrote:
> We received a bug report ([ruby-dev:44011] [Ruby 1.9 - Bug #4958], in
> Japanese) that says Passenger (*1) doesn't work with current trunk.  I
> surveyed it and found out the reason.
> 
> *1: http://www.modrails.com/
> 
> In short, Passenger close most of file descriptors (fd) by
> NativeSupport.close_all_file_descriptors().  However, current Ruby uses
> 2 fds for to communicate between [signal handler] <-> [timer thread] <->
> [ruby thread].  I can run Passenger on commented out
> "NativeSupport.close_all_file_descriptors" line.

...

> (4) Solution
> 
> How to solve it?  May I provide some C API or Ruby API to get pipe fds?

I made a new C API "rb_reserved_fd_p(int fd)" at r32394.

> 	* include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,
> 	  RB_RESERVED_FD_P): added.  This C API is to limit to access
> 	  fds which are used by RubyVM internal.  In this version of
> 	  CRuby, return 1 if fd is communication pipe.
> 	  If your application needs to close all file descriptors to
> 	  preent resource leak, skip internal fds using this C API.
> 	  We also define a macro RB_RESERVED_FD_P(fd).  So you can write
> 	    #ifndef RB_RESERVED_FD_P
> 	    #define RB_RESERVED_FD_P(fd) 0
> 	    #endif
> 	  for Ruby 1.9.2 or previous version to write compatible extensions.
> 	  See [ruby-core:37727]

Could you use it to skip internal file descriptors?

-- 
// SASADA Koichi at atdot dot net