From: dmitry kim Date: Thu, 17 Apr 2008 21:38:31 +0000 (+0400) Subject: * make the daemonization thing to suck less (wrt standard io channels) X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;ds=inline;h=96d13521d82d4fa4355faf9dd3b8aace86171c87;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git * make the daemonization thing to suck less (wrt standard io channels) --- diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 01b9d5b6..6a1c8f67 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -463,17 +463,20 @@ class Bot Dir.chdir botclass # File.umask 0000 # Ensure sensible umask. Adjust as needed. log "Redirecting standard input/output/error" - begin - STDIN.reopen "/dev/null" - rescue Errno::ENOENT - # On Windows, there's not such thing as /dev/null - STDIN.reopen "NUL" + [$stdin, $stdout, $stderr].each do |fd| + begin + fd.reopen "/dev/null" + rescue Errno::ENOENT + # On Windows, there's not such thing as /dev/null + fd.reopen "NUL" + end end - def STDOUT.write(str=nil) + + def $stdout.write(str=nil) log str, 2 return str.to_s.size end - def STDERR.write(str=nil) + def $stdout.write(str=nil) if str.to_s.match(/:\d+: warning:/) warning str, 2 else