Skip to content

Commit

Permalink
Merge pull request #86 from kennethkalmer/untouched-ios
Browse files Browse the repository at this point in the history
fix: stop closing IO's we don't own, fixes #85
  • Loading branch information
marcbowes committed Dec 5, 2014
2 parents 09d1ba4 + be4caae commit 38c949a
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions lib/daemon_kit/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ def exec( file )
# Run the daemon in the foreground without daemonizing
def run( file )
self.chroot
self.clean_fd
self.redirect_io( true )

DaemonKit.configuration.log_stdout = true

require file
Expand All @@ -43,7 +42,6 @@ def start( file )
self.drop_privileges
self.daemonize
self.chroot
self.clean_fd
self.redirect_io

require file
Expand Down Expand Up @@ -177,21 +175,6 @@ def chroot
File.umask 0000
end

# Make sure all file descriptors are closed (with the exception
# of STDIN, STDOUT & STDERR)
def clean_fd
ObjectSpace.each_object(IO) do |io|
unless [STDIN, STDOUT, STDERR].include?(io)
begin
unless io.closed?
io.close
end
rescue ::Exception
end
end
end
end

# Redirect our IO
# TODO: make this configurable
def redirect_io( simulate = false )
Expand Down

0 comments on commit 38c949a

Please sign in to comment.