From 74bbd50328663257c8ee135be7fd2532ef7d1933 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 9 Jul 2009 01:19:24 -0700 Subject: always set FD_CLOEXEC on sockets post-accept() FD_CLOEXEC is not guaranteed to be inherited by the accept()-ed descriptors even if the listener socket has this set. This can be a problem with applications that fork+exec long running background processes. Thanks to Paul Sponagl for helping me find this. --- lib/unicorn.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index e0dd4ef..aac530b 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -436,6 +436,7 @@ module Unicorn # once a client is accepted, it is processed in its entirety here # in 3 easy steps: read request, call app, write app response def process_client(app, client) + client.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) HttpResponse.write(client, app.call(REQUEST.read(client))) # if we get any error, try to write something back to the client # assuming we haven't closed the socket, but don't get hung up -- cgit v1.2.3-24-ge0c7