From 96d13521d82d4fa4355faf9dd3b8aace86171c87 Mon Sep 17 00:00:00 2001 From: dmitry kim Date: Fri, 18 Apr 2008 01:38:31 +0400 Subject: * make the daemonization thing to suck less (wrt standard io channels) --- lib/rbot/ircbot.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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 -- cgit v1.2.3