From 2ee9353fba7be5443db2ccdc3541586932ccf1f1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 8 Dec 2018 17:33:51 +0000 Subject: remove IO#close_on_exec= calls Since we've required Ruby 2.0+ for a while, we can assume descriptors are created with IO#close_on_exec=true and avoid bloating our code with calls to it. --- lib/yahns/config.rb | 2 +- lib/yahns/daemon.rb | 1 - lib/yahns/queue_kqueue.rb | 6 ------ lib/yahns/queue_quitter_pipe.rb | 1 - lib/yahns/sigevent_pipe.rb | 1 - lib/yahns/socket_helper.rb | 2 +- 6 files changed, 2 insertions(+), 11 deletions(-) (limited to 'lib/yahns') diff --git a/lib/yahns/config.rb b/lib/yahns/config.rb index bcea0d4..e64cb77 100644 --- a/lib/yahns/config.rb +++ b/lib/yahns/config.rb @@ -409,7 +409,7 @@ class Yahns::Config # :nodoc: if String === val # we've already bound working_directory by the time we get here val = File.open(File.expand_path(val), "ab") - val.close_on_exec = val.sync = true + val.sync = true else rt = [ :puts, :write, :flush ] # match Rack::Lint rt.all? { |m| val.respond_to?(m) } or raise ArgumentError, diff --git a/lib/yahns/daemon.rb b/lib/yahns/daemon.rb index e3e2d9c..cca2f3a 100644 --- a/lib/yahns/daemon.rb +++ b/lib/yahns/daemon.rb @@ -32,7 +32,6 @@ module Yahns::Daemon # :nodoc: # We cannot use Yahns::Sigevent (eventfd) here because we need # to detect EOF on unexpected death, not just read/write rd, wr = IO.pipe - rd.close_on_exec = wr.close_on_exec = true grandparent = $$ if fork wr.close # grandparent does not write diff --git a/lib/yahns/queue_kqueue.rb b/lib/yahns/queue_kqueue.rb index 064cd0e..3c4c51c 100644 --- a/lib/yahns/queue_kqueue.rb +++ b/lib/yahns/queue_kqueue.rb @@ -17,12 +17,6 @@ class Yahns::Queue < SleepyPenguin::Kqueue::IO # :nodoc: ADD_ONESHOT = Ev::ADD | Ev::ONESHOT # private - def self.new - rv = super - rv.close_on_exec = true - rv - end - # for HTTP and HTTPS servers, we rely on the io writing to us, first # flags: QEV_RD/QEV_WR (usually QEV_RD) def queue_add(io, flags) diff --git a/lib/yahns/queue_quitter_pipe.rb b/lib/yahns/queue_quitter_pipe.rb index 789eacd..9a2e494 100644 --- a/lib/yahns/queue_quitter_pipe.rb +++ b/lib/yahns/queue_quitter_pipe.rb @@ -7,7 +7,6 @@ class Yahns::QueueQuitter # :nodoc: attr_reader :to_io def initialize @reader, @to_io = IO.pipe - @to_io.close_on_exec = true end def yahns_step diff --git a/lib/yahns/sigevent_pipe.rb b/lib/yahns/sigevent_pipe.rb index a85fb2a..f630e72 100644 --- a/lib/yahns/sigevent_pipe.rb +++ b/lib/yahns/sigevent_pipe.rb @@ -6,7 +6,6 @@ class Yahns::Sigevent # :nodoc: attr_reader :to_io def initialize @to_io, @wr = Kgio::Pipe.new - @to_io.close_on_exec = @wr.close_on_exec = true end def kgio_wait_readable(*args) diff --git a/lib/yahns/socket_helper.rb b/lib/yahns/socket_helper.rb index 9d4afc0..963c9fa 100644 --- a/lib/yahns/socket_helper.rb +++ b/lib/yahns/socket_helper.rb @@ -19,7 +19,7 @@ module Yahns::SocketHelper # :nodoc: def set_server_sockopt(sock, opt) opt = {backlog: 1024}.merge!(opt) - sock.close_on_exec = true + sock.close_on_exec = true # needed for inherited sockets TCPSocket === sock and sock.setsockopt(:IPPROTO_TCP, :TCP_NODELAY, 1) sock.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, 1) -- cgit v1.2.3-24-ge0c7