Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Wed, 11 May 2005 04:29:41 +0000 (04:29 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Wed, 11 May 2005 04:29:41 +0000 (04:29 +0000)
Log message:

Fix server restart loop problem when debugging is enabled.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1404 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/ircd.c

index 11c9d8bb9a1d2294d18b6b5b432922df9fc88b00..8757461e82bb8a6931cb8b59ddda2c66b97c2e52 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-05-11  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/ircd.c: if debugging is enabled (both DEBUGMODE defined and
+       -x given), reserve fd 2 for the use of the debugging log;
+       otherwise, some engines may attempt to use fd 2, which would end
+       up getting closed by debug_init() (actually, by
+       log_debug_reopen(), called by log_debug_init(), called by
+       debug_init())
+
 2005-08-10  Michael Poole <mdpoole@troilus.org>
 
        * ircd/channel.c (joinbuf_join): Do not send a MODE +o when a
index f2903003fdc476ef3068d3068aa80b51cc0b3bdd..ec86bf1aabf82a25006876f52d6e2a5bb4a422c0 100644 (file)
@@ -656,6 +656,23 @@ int main(int argc, char **argv) {
    */
   daemon_init(thisServer.bootopt & BOOT_TTY);
 
+#ifdef DEBUGMODE
+  /* Must reserve fd 2... */
+  if (debuglevel >= 0 && !(thisServer.bootopt & BOOT_TTY)) {
+    int fd;
+    if ((fd = open("/dev/null", O_WRONLY)) < 0) {
+      fprintf(stderr, "Unable to open /dev/null (to reserve fd 2): %s\n",
+             strerror(errno));
+      return 8;
+    }
+    if (fd != 2 && dup2(fd, 2) < 0) {
+      fprintf(stderr, "Unable to reserve fd 2; dup2 said: %s\n",
+             strerror(errno));
+      return 8;
+    }
+  }
+#endif
+
   event_init(MAXCONNECTIONS);
 
   setup_signals();