X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/b6c680d45c9045b6e5f2350f3dd172e569f7c65d..b41069ff844e8d8e24da43b7f777801be1a55390:/window.c diff --git a/window.c b/window.c index c1f3fac2..cdc58dc3 100644 --- a/window.c +++ b/window.c @@ -667,7 +667,7 @@ void connection_fatal(char *fmt, ...) { vsprintf(stuff, fmt, ap); va_end(ap); MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK); - if (cfg.close_on_exit) + if (cfg.close_on_exit == COE_ALWAYS) PostQuitMessage(1); else { session_closed = TRUE; @@ -692,16 +692,17 @@ static void enact_pending_netevent(void) { ret = select_result (pend_netevent_wParam, pend_netevent_lParam); reentering = 0; - if (ret == 0) { - if (cfg.close_on_exit) + if (ret == 0 && !session_closed) { + /* Abnormal exits will already have set session_closed and taken + * appropriate action. */ + if (cfg.close_on_exit == COE_ALWAYS || + cfg.close_on_exit == COE_NORMAL) PostQuitMessage(0); else { - if (!session_closed) { - session_closed = TRUE; - SetWindowText (hwnd, "PuTTY (inactive)"); - MessageBox(hwnd, "Connection closed by remote host", - "PuTTY", MB_OK | MB_ICONINFORMATION); - } + session_closed = TRUE; + SetWindowText (hwnd, "PuTTY (inactive)"); + MessageBox(hwnd, "Connection closed by remote host", + "PuTTY", MB_OK | MB_ICONINFORMATION); } } }