From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.mongrel.devel,gmane.comp.sysutils.puppet.devel Subject: Re: Mongrel doesn't set close-on-exec on its listen socket Date: Mon, 18 Aug 2008 14:59:21 -0700 Message-ID: <20080818215844.GA1441@yp-box.dyndns.org> References: <20080722163104.GA82787@lizzy.catnook.local> Reply-To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1219096786 29800 80.91.229.12 (18 Aug 2008 21:59:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Aug 2008 21:59:46 +0000 (UTC) Cc: puppet-dev-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Tue Aug 19 00:00:35 2008 Return-path: Envelope-to: gclrmd-mongrel-development@m.gmane.org Content-Disposition: inline In-Reply-To: <20080722163104.GA82787-/yjMewivvDbpLr52UxKYZsM6rOWSkUom@public.gmane.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.mongrel.devel:63 gmane.comp.sysutils.puppet.devel:4531 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1KVCm4-0000LA-Df for gclrmd-mongrel-development@m.gmane.org; Tue, 19 Aug 2008 00:00:28 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 1DFED18585B5; Mon, 18 Aug 2008 17:59:28 -0400 (EDT) Received: from hand.yhbt.net (hand.yhbt.net [66.150.188.102]) by rubyforge.org (Postfix) with ESMTP id 1CB9A18585A7 for ; Mon, 18 Aug 2008 17:59:22 -0400 (EDT) Received: from localhost.localdomain (localhost [127.0.0.1]) by hand.yhbt.net (Postfix) with ESMTP id 7DF852DC01B; Mon, 18 Aug 2008 14:59:21 -0700 (PDT) List-Post: Jos Backus wrote: > Mongrel, at least in 1.1.4, doesn't set the close-on-exec flag on the listen > socket. This leads to trouble in programs that use Mongrel and fork other > programs (like puppetmasterd, part of Puppet). For an example, see > http://groups.google.com/group/puppet-dev/browse_thread/thread/463f0f8cfc80cc43 > > Please consider applying something like the following patch: > > --- lib/mongrel.rb.orig 2008-07-17 17:44:42.000000000 -0400 > +++ lib/mongrel.rb 2008-07-17 17:44:53.000000000 -0400 > @@ -92,7 +92,9 @@ > > tries = 0 > @socket = TCPServer.new(host, port) > + @socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) > + > @classifier = URIClassifier.new > @host = host > @port = port > > If somebody can show me what the Mongrel way of making this (POSIX) > platform-specific, that would be appreciated. This probably works: diff --git a/lib/mongrel.rb b/lib/mongrel.rb index 8b5dfe2..027bfdb 100644 --- a/lib/mongrel.rb +++ b/lib/mongrel.rb @@ -91,6 +91,9 @@ module Mongrel tries = 0 @socket = TCPServer.new(host, port) + if defined?(Fcntl::FD_CLOEXEC) + @socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + end @classifier = URIClassifier.new @host = host -- Eric Wong