# File lib/childprocess.rb, line 141 def close_on_exec(file) if file.respond_to?(:close_on_exec=) file.close_on_exec = true elsif file.respond_to?(:fcntl) && defined?(Fcntl::FD_CLOEXEC) file.fcntl Fcntl::F_SETFD, Fcntl::FD_CLOEXEC if jruby? && posix_spawn? # on JRuby, the fcntl call above apparently isn't enough when # we're launching the process through posix_spawn. fileno = JRuby.posix_fileno_for(file) Unix::Lib.fcntl fileno, Fcntl::F_SETFD, Fcntl::FD_CLOEXEC end elsif windows? Windows::Lib.dont_inherit file else raise Error, "not sure how to set close-on-exec for #{file.inspect} on #{platform_name.inspect}" end end