1diff -uNr sent-upstream/as-sent-last/include/config.h ircii-pana-1.0-0c15/include/config.h 2--- sent-upstream/as-sent-last/include/config.h Sat Jan 8 04:19:04 2000 3+++ ircii-pana-1.0-0c15/include/config.h Sun Jan 9 06:40:56 2000 4@@ -571,7 +571,7 @@ 5 #define WANT_DETACH ON /* this is here for the detach/re-attach code 6 which is essentially a mini-screen */ 7 #define ALLOW_DETACH ON 8- 9+#define DEFAULT_DETACH_ON_HUP ON 10 11 #undef OLD_RANDOM_BEHAVIOR /* semi randomness for randm() */ 12 13diff -uNr sent-upstream/as-sent-last/include/modval.h ircii-pana-1.0-0c15/include/modval.h 14--- sent-upstream/as-sent-last/include/modval.h Tue Jan 4 01:54:48 2000 15+++ ircii-pana-1.0-0c15/include/modval.h Sun Jan 9 06:01:54 2000 16@@ -306,6 +306,7 @@ 17 #define get_window_server(x) ((int) (global[GET_WINDOW_SERVER]((unsigned int)x))) 18 #define set_window_server(x, y, z) ((void) (global[SET_WINDOW_SERVER]((int)x, (int)y, (int)z))) 19 #define window_check_servers ((void (*)())global[WINDOW_CHECK_SERVERS]) 20+#define window_close_server ((void (*)(int))global[WINDOW_CHECK_SERVERS]) 21 #define change_window_server(x, y) ((void) (global[CHANGE_WINDOW_SERVER]((int)x, (int)y))) 22 #define set_level_by_refnum(x, y) ((void) (global[SET_LEVEL_BY_REFNUM]((unsigned int)x, (int)y))) 23 #define message_to(x) ((void) (global[MESSAGE_TO]((unsigned int)x))) 24diff -uNr sent-upstream/as-sent-last/include/struct.h ircii-pana-1.0-0c15/include/struct.h 25--- sent-upstream/as-sent-last/include/struct.h Tue Jan 4 02:27:26 2000 26+++ ircii-pana-1.0-0c15/include/struct.h Sun Jan 9 06:13:17 2000 27@@ -593,6 +593,7 @@ 28 unsigned int refnum; /* the unique reference number, 29 * assigned by IRCII */ 30 int server; /* server index */ 31+ int last_server; /* previous server index */ 32 int top; /* The top line of the window, screen 33 * coordinates */ 34 int bottom; /* The botton line of the window, screen 35diff -uNr sent-upstream/as-sent-last/include/vars.h ircii-pana-1.0-0c15/include/vars.h 36--- sent-upstream/as-sent-last/include/vars.h Tue Jan 4 02:27:26 2000 37+++ ircii-pana-1.0-0c15/include/vars.h Sun Jan 9 06:41:24 2000 38@@ -103,6 +103,7 @@ 39 DEOPFLOOD_TIME_VAR, 40 DEOP_ON_DEOPFLOOD_VAR, 41 DEOP_ON_KICKFLOOD_VAR, 42+ DETACH_ON_HUP, 43 DISPATCH_UNKNOWN_COMMANDS_VAR, 44 DISPLAY_VAR , 45 DISPLAY_ANSI_VAR, 46diff -uNr sent-upstream/as-sent-last/include/window.h ircii-pana-1.0-0c15/include/window.h 47--- sent-upstream/as-sent-last/include/window.h Fri Oct 22 01:48:21 1999 48+++ ircii-pana-1.0-0c15/include/window.h Sun Jan 9 06:03:52 2000 49@@ -31,6 +31,10 @@ 50 #define ON 1 51 #define TOGGLE 2 52 53+#define WINDOW_NO_SERVER -1 54+#define WINDOW_DLL -2 55+#define WINDOW_SERVER_CLOSED -3 56+ 57 Window *new_window (struct ScreenStru *); 58 void delete_window (Window *); 59 void add_to_invisible_list (Window *); 60@@ -71,7 +75,6 @@ 61 char *get_bound_channel (Window *); 62 int get_window_server (unsigned); 63 void set_window_server (int, int, int); 64- void window_check_servers (void); 65 void set_level_by_refnum (unsigned, unsigned long); 66 void message_to (unsigned long); 67 68@@ -145,6 +148,7 @@ 69 const char *query_host (void); 70 const char *query_cmd (void); 71 void window_check_servers(void); 72+ void window_close_server(int old_server); 73 void window_change_server(int, int); 74 void make_window_current_by_winref(int); 75 void make_window_current_by_desc(char *); 76diff -uNr sent-upstream/as-sent-last/source/commands.c ircii-pana-1.0-0c15/source/commands.c 77--- sent-upstream/as-sent-last/source/commands.c Tue Jan 4 01:43:35 2000 78+++ ircii-pana-1.0-0c15/source/commands.c Sun Jan 9 06:05:49 2000 79@@ -1075,7 +1075,7 @@ 80 set_server_reconnect(from_server, 1); 81 close_server(from_server,(args && *args) ? args : "Reconnecting"); 82 clean_server_queues(from_server); 83- window_check_servers(); 84+ window_close_server(from_server); 85 servercmd(NULL, scommnd, empty_string, NULL); 86 87 } 88diff -uNr sent-upstream/as-sent-last/source/irc.c ircii-pana-1.0-0c15/source/irc.c 89--- sent-upstream/as-sent-last/source/irc.c Sat Jan 8 04:19:04 2000 90+++ ircii-pana-1.0-0c15/source/irc.c Sun Jan 9 06:49:38 2000 91@@ -543,6 +543,14 @@ 92 detachcmd(NULL, NULL, NULL, NULL); 93 } 94 95+void set_detach_on_hup(Window *dummy, char *unused, int value) 96+{ 97+ if(value) 98+ my_signal(SIGHUP, sig_detach, 0); 99+ else 100+ my_signal(SIGHUP, irc_exit_old, 0); 101+} 102+ 103 /* shows the version of irc */ 104 static void versionreply(void) 105 { 106@@ -1506,7 +1514,7 @@ 107 #endif 108 my_signal(SIGQUIT, SIG_IGN, 0); 109 #ifdef WANT_DETACH 110- my_signal(SIGHUP, sig_detach, 0); 111+ set_detach_on_hup(NULL, NULL, DEFAULT_DETACH_ON_HUP); 112 #else 113 my_signal(SIGHUP, irc_exit_old, 0); 114 #endif 115diff -uNr sent-upstream/as-sent-last/source/numbers.c ircii-pana-1.0-0c15/source/numbers.c 116--- sent-upstream/as-sent-last/source/numbers.c Sat Jan 1 19:24:50 2000 117+++ ircii-pana-1.0-0c15/source/numbers.c Sun Jan 9 06:06:34 2000 118@@ -1105,7 +1105,7 @@ 119 if (do_hook(current_numeric, "%s %s", from, *ArgList)) 120 display_msg(from, ArgList); 121 close_server(from_server, empty_string); 122- window_check_servers(); 123+ window_close_server(from_server); 124 if (from_server == primary_server) 125 get_connected(from_server + 1, from_server); 126 break; 127@@ -1149,7 +1149,7 @@ 128 display_msg(from, ArgList); 129 130 close_server(from_server, empty_string); 131- window_check_servers(); 132+ window_close_server(from_server); 133 if (server_list_size() > 1) 134 remove_from_server_list(klined); 135 if (klined == primary_server && (server_list_size() > 0)) 136diff -uNr sent-upstream/as-sent-last/source/parse.c ircii-pana-1.0-0c15/source/parse.c 137--- sent-upstream/as-sent-last/source/parse.c Tue Jan 4 02:30:07 2000 138+++ ircii-pana-1.0-0c15/source/parse.c Sun Jan 9 06:06:48 2000 139@@ -1166,7 +1166,7 @@ 140 141 close_server(from_server,empty_string); 142 clean_server_queues(from_server); 143- window_check_servers(); 144+ window_close_server(from_server); 145 set_input_prompt(current_window, get_string_var(INPUT_PROMPT_VAR), 0); 146 if (strchr(from, '.')) 147 { 148diff -uNr sent-upstream/as-sent-last/source/server.c ircii-pana-1.0-0c15/source/server.c 149--- sent-upstream/as-sent-last/source/server.c Tue Jan 4 01:43:35 2000 150+++ ircii-pana-1.0-0c15/source/server.c Sun Jan 9 06:25:16 2000 151@@ -257,6 +257,7 @@ 152 times = 1; 153 i++; 154 } 155+ window_close_server(i); 156 get_connected(i, old_serv); 157 break; 158 } 159@@ -1162,7 +1163,7 @@ 160 return; 161 } 162 close_server(i, "closing server"); 163- window_check_servers(); 164+ window_close_server(i); 165 } 166 else 167 get_connected(from_server - 1, from_server); 168@@ -2100,6 +2101,7 @@ 169 clear_channel_list(i); 170 close_server(i, message); 171 server_list[i].eof = 1; 172+ window_close_server(i); 173 } 174 done: 175 window_check_servers(); 176diff -uNr sent-upstream/as-sent-last/source/vars.c ircii-pana-1.0-0c15/source/vars.c 177--- sent-upstream/as-sent-last/source/vars.c Tue Jan 4 02:27:26 2000 178+++ ircii-pana-1.0-0c15/source/vars.c Sun Jan 9 06:52:18 2000 179@@ -95,6 +95,8 @@ 180 static void set_nat_address (Window *, char *, int); 181 extern void debug_window (Window *, char *, int); 182 183+extern void set_detach_on_hup (Window *, char *, int); 184+ 185 /* 186 * irc_variable: all the irc variables used. Note that the integer and 187 * boolean defaults are set here, which the string default value are set in 188@@ -199,6 +201,7 @@ 189 { "DEOPFLOOD_TIME",0, INT_TYPE_VAR, DEFAULT_DEOPFLOOD_TIME, NULL, NULL, 0, VIF_BITCHX }, 190 { "DEOP_ON_DEOPFLOOD",0, INT_TYPE_VAR, DEFAULT_DEOP_ON_DEOPFLOOD, NULL, NULL, 0, VIF_BITCHX }, 191 { "DEOP_ON_KICKFLOOD",0, INT_TYPE_VAR, DEFAULT_DEOP_ON_KICKFLOOD, NULL, NULL, 0, VIF_BITCHX }, 192+ { "DETACH_ON_HUP",0, BOOL_TYPE_VAR, DEFAULT_DETACH_ON_HUP, NULL, set_detach_on_hup, 0, 0 }, 193 { "DISPATCH_UNKNOWN_COMMANDS",0,BOOL_TYPE_VAR, DEFAULT_DISPATCH_UNKNOWN_COMMANDS, NULL, NULL, 0, 0 }, 194 { "DISPLAY",0, BOOL_TYPE_VAR, DEFAULT_DISPLAY, NULL, NULL, 0, 0 }, 195 { "DISPLAY_ANSI",0, BOOL_TYPE_VAR, DEFAULT_DISPLAY_ANSI, NULL, toggle_reverse_status, 0, 0 }, 196diff -uNr sent-upstream/as-sent-last/source/window.c ircii-pana-1.0-0c15/source/window.c 197--- sent-upstream/as-sent-last/source/window.c Tue Jan 4 02:27:26 2000 198+++ ircii-pana-1.0-0c15/source/window.c Sun Jan 9 06:18:15 2000 199@@ -1784,7 +1784,7 @@ 200 if ((window = get_window_by_refnum(refnum)) == NULL) 201 window = current_window; 202 old = window->server; 203- if (misc) 204+ if (misc || old == WINDOW_SERVER_CLOSED) 205 { 206 while ((traverse_all_windows(&tmp))) 207 { 208@@ -1850,6 +1850,30 @@ 209 } 210 update_all_status(current_window, NULL, 0); 211 cursor_to_input(); 212+} 213+ 214+/* 215+ * window_close_server: this is like window_check_servers but it gets called 216+ * with old_server as the refnum of a server that just got closed. It marks 217+ * every window that used to be connected to old_server as WINDOW_SERVER_CLOSED 218+ * and sets last_server for those windows. It doesn't touch windows that 219+ * already had no server. 220+ */ 221+ 222+void window_close_server(int old_server) 223+{ 224+ Window *tmp; 225+ int cnt, max, i, not_connected, prime = -1; 226+ 227+ tmp = NULL; 228+ while ((traverse_all_windows(&tmp))) 229+ { 230+ if (tmp->server == old_server) 231+ { 232+ tmp->server = WINDOW_SERVER_CLOSED; 233+ tmp->last_server = old_server; 234+ } 235+ } 236 } 237 238 /* 239