diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-02-09 21:44:46 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-02-09 21:44:46 -0800 |
commit | c91853669716f40175562b77e540a396d2e79799 (patch) | |
tree | 434df4fb7b3a2594e2635077bffa9d55ce958238 | |
parent | 5a842b0621516d4a74dadd391b495eaa6ec60744 (diff) | |
download | unicorn-c91853669716f40175562b77e540a396d2e79799.tar.gz |
Don't rely on FD_CLOEXEC if we don't have to since it may not be completely portable. Just explicitly close things (pipes, tempfiles) we don't want to pass on to our children when forking.
-rw-r--r-- | lib/unicorn.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 2e7a1a9..a33b1b2 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -153,7 +153,6 @@ module Unicorn # this pipe is used to wake us up from select(2) in #join when signals # are trapped. See trap_deferred @rd_sig, @wr_sig = IO.pipe.map do |io| - set_cloexec(io) io.nonblock = true io end unless (@rd_sig && @wr_sig) @@ -268,6 +267,10 @@ module Unicorn # Returns the pid of the forked process def spawn_start_ctx(check = nil) fork do + @rd_sig.close if @rd_sig + @wr_sig.close if @wr_sig + @workers.values.each { |other| other.tempfile.close rescue nil } + ENV.replace(@start_ctx[:environ]) ENV['UNICORN_FD'] = @listeners.map { |sock| sock.fileno }.join(',') File.umask(@start_ctx[:umask]) |