[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] [Win32 Patch] console-close events
From: |
Gisle Vanem |
Subject: |
Re: [Bug-wget] [Win32 Patch] console-close events |
Date: |
Tue, 17 Jun 2014 01:06:06 +0200 |
"Ángel González" <address@hidden> wrote:
+ event == CTRL_SHUTDOWN_EVENT ? "CTRL_SHUTDOWN_EVENT" :
+ "?");
Better something like "UNKNOWN EVENT" ?
Ok. That seems better.
PS. The above Sleep() seems to be ignored by WinCon. At least I failed to
make it sleep more than ~500 msec.
There may be a timeout on how long you can stay processing the event.
Why do you need that Sleep() call at all? I would remove it.
When logging to the console (no '-o log-file' option), the Sleep(500) will make
the final "... cleanup." message stay a tiny bit longer (but barely readable).
Without a Sleep(), the console gets closed with only a message-beep.
Thanks for sharing your patch!
Thanks for the interest. Do you build Wget on Win32? Anybody else
except me build and care about Wget/Win32 here?
Revised patch:
--- mswindows.c.orig 2014-06-12 13:02:44 +0000
+++ mswindows.c 2014-06-17 00:58:08 +0000
@@ -42,6 +42,7 @@
#include "utils.h"
#include "url.h"
+#include "init.h"
#ifndef ES_SYSTEM_REQUIRED
#define ES_SYSTEM_REQUIRED 0x00000001
@@ -337,6 +338,17 @@
/* If we get here, we're the child. */
}
+/* Return the name for the console-events we might receive. */
+static const char *ws_event_name (DWORD event)
+{
+ return (event == CTRL_C_EVENT ? "CTRL_C_EVENT" :
+ event == CTRL_BREAK_EVENT ? "CTRL_BREAK_EVENT" :
+ event == CTRL_CLOSE_EVENT ? "CTRL_CLOSE_EVENT" :
+ event == CTRL_LOGOFF_EVENT ? "CTRL_LOGOFF_EVENT" :
+ event == CTRL_SHUTDOWN_EVENT ? "CTRL_SHUTDOWN_EVENT" :
+ "UNKNOWN EVENT");
+}
+
static BOOL WINAPI
ws_handler (DWORD dwEvent)
{
@@ -352,6 +364,16 @@
ws_hangup ("CTRL+Break");
return TRUE;
#endif
+ case CTRL_CLOSE_EVENT:
+ case CTRL_LOGOFF_EVENT:
+ case CTRL_SHUTDOWN_EVENT:
+ MessageBeep (MB_OK);
+ logprintf (LOG_NOTQUIET, _("\nGot %s. Performing cleanup.\n"),
+ ws_event_name(dwEvent));
+ cleanup();
+ Sleep(500);
+ return TRUE;
+
default:
return FALSE;
}
----------------------------------
--gv