From 6d7dc29a78247c1ea5011efaec9ae6a175d8ccb6 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Wed, 11 May 2005 04:29:41 +0000 Subject: [PATCH] Author: Kev 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 | 9 +++++++++ ircd/ircd.c | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ChangeLog b/ChangeLog index 11c9d8b..8757461 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-05-11 Kevin L. Mitchell + + * 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 * ircd/channel.c (joinbuf_join): Do not send a MODE +o when a diff --git a/ircd/ircd.c b/ircd/ircd.c index f290300..ec86bf1 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -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(); -- 2.20.1