about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-07-09 01:19:24 -0700
committerEric Wong <normalperson@yhbt.net>2009-07-09 01:25:31 -0700
commit74bbd50328663257c8ee135be7fd2532ef7d1933 (patch)
treec37f21268d225a9fe7e0252803112cffe745aa8a
parentc8baa439a99d6a898ee3d5b980390a36d23eea2e (diff)
downloadunicorn-74bbd50328663257c8ee135be7fd2532ef7d1933.tar.gz
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.
-rw-r--r--lib/unicorn.rb1
1 files changed, 1 insertions, 0 deletions
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