Create the flush thread on first use
Some processes just return from the entry point; this only exits the thread, not the process. It seems that when ANSICON created its flush thread in DllMain, that became the primary thread, so when the entry point returned the process was still waiting for the flush thread to exit. Creating the flush thread the first time it is used avoids this problem, letting the process exit.
This commit is contained in:
parent
c232c1ff37
commit
3a16e68201
8
ANSI.c
8
ANSI.c
@ -193,6 +193,9 @@
|
||||
flush and invalidate the cache on CloseHandle;
|
||||
make IsConsoleHandle a critical section, for multithreaded processes;
|
||||
use APIConsole for all console functions (needed for Windows 10).
|
||||
|
||||
v1.83, 16 February, 2018:
|
||||
create the flush thread on first use.
|
||||
*/
|
||||
|
||||
#include "ansicon.h"
|
||||
@ -212,7 +215,7 @@ WORD orgattr; // original attributes
|
||||
DWORD orgmode; // original mode
|
||||
CONSOLE_CURSOR_INFO orgcci; // original cursor state
|
||||
HANDLE hHeap; // local memory heap
|
||||
HANDLE hBell;
|
||||
HANDLE hBell, hFlush;
|
||||
|
||||
#define CACHE 5
|
||||
struct Cache
|
||||
@ -2528,6 +2531,8 @@ ParseAndPrintString( HANDLE hDev,
|
||||
{
|
||||
LARGE_INTEGER due;
|
||||
due.QuadPart = -150000;
|
||||
if (hFlush == NULL)
|
||||
hFlush = CreateThread( NULL, 4096, FlushThread, NULL, 0, NULL );
|
||||
SetWaitableTimer( hFlushTimer, &due, 0, NULL, NULL, FALSE );
|
||||
}
|
||||
}
|
||||
@ -3897,7 +3902,6 @@ BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved )
|
||||
|
||||
InitializeCriticalSection( &CritSect );
|
||||
hFlushTimer = CreateWaitableTimer( NULL, FALSE, NULL );
|
||||
CreateThread( NULL, 4096, FlushThread, NULL, 0, NULL );
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
|
@ -91,7 +91,7 @@
|
||||
use -pu to unload from the parent.
|
||||
*/
|
||||
|
||||
#define PDATE L"13 February, 2018"
|
||||
#define PDATE L"16 February, 2018"
|
||||
|
||||
#include "ansicon.h"
|
||||
#include "version.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
Copyright 2005-2018 Jason Hood
|
||||
|
||||
Version 1.82. Freeware
|
||||
Version 1.83. Freeware
|
||||
|
||||
|
||||
Description
|
||||
@ -339,6 +339,9 @@ Version History
|
||||
|
||||
Legend: + added, - bug-fixed, * changed.
|
||||
|
||||
1.83 - 16 February, 2018:
|
||||
- create the flush thread on first use.
|
||||
|
||||
1.82 - 13 February, 2018:
|
||||
- add ANSICON_WRAP for programs that expect the wrap at right margin;
|
||||
- make IsConsoleHandle a critical section, for multithreaded processes;
|
||||
@ -610,4 +613,4 @@ Distribution
|
||||
|
||||
|
||||
==============================
|
||||
Jason Hood, 13 February, 2018.
|
||||
Jason Hood, 16 February, 2018.
|
||||
|
10
version.h
10
version.h
@ -2,11 +2,11 @@
|
||||
version.h - Version defines.
|
||||
*/
|
||||
|
||||
#define PVERS L"1.82" // wide string
|
||||
#define PVERSA "1.82" // ANSI string (windres 2.16.91 didn't like L)
|
||||
#define PVERE L"182" // wide environment string
|
||||
#define PVEREA "182" // ANSI environment string
|
||||
#define PVERB 1,8,2,0 // binary (resource)
|
||||
#define PVERS L"1.83" // wide string
|
||||
#define PVERSA "1.83" // ANSI string (windres 2.16.91 didn't like L)
|
||||
#define PVERE L"183" // wide environment string
|
||||
#define PVEREA "183" // ANSI environment string
|
||||
#define PVERB 1,8,3,0 // binary (resource)
|
||||
|
||||
#ifdef _WIN64
|
||||
# define BITS L"64"
|
||||
|
Loading…
x
Reference in New Issue
Block a user