Method: Daemonize.close_io
- Defined in:
- lib/daemons/daemonize.rb
.close_io ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/daemons/daemonize.rb', line 121 def close_io # Make sure all input/output streams are closed # Part I: close all IO objects (except for $stdin/$stdout/$stderr) ObjectSpace.each_object(IO) do |io| unless [$stdin, $stdout, $stderr].include?(io) io.close rescue nil end end # Make sure all input/output streams are closed # Part II: close all file decriptors (except for $stdin/$stdout/$stderr) 3.upto(8192) do |i| IO.for_fd(i).close rescue nil end end |