]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
* make the daemonization thing to suck less (wrt standard io channels)
authordmitry kim <jason@nichego.net>
Thu, 17 Apr 2008 21:38:31 +0000 (01:38 +0400)
committerdmitry kim <jason@nichego.net>
Thu, 17 Apr 2008 21:38:31 +0000 (01:38 +0400)
lib/rbot/ircbot.rb

index 01b9d5b636018a06c429ecd458ab120951e7d343..6a1c8f6758472f9ba5da84ba432b594e298947b4 100644 (file)
@@ -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