I have this program.cpp :
#include <stdio.h>
#include <windows.h>
DWORD WINAPI separateThread(LPVOID)
{ printf("thread waiting user input\n");
char str[128]; fgets(str, 128, stdin);
printf("fgets END ...");
}
int main()
{
printf("program start autokill after 5sec\n");
DWORD tid; HANDLE tha =CreateThread(0,0, separateThread, 0,0,&tid);
Sleep(5000);
// XXXXXXXX what to put here to Kill fgets-callin-thread ???????????
}
compiled in linux with:
i686-w64-mingw32-gcc program.cpp
and running it with:
wine a.exe
... and I want it to be ended itself, WITHOUT ANY USER INPUT. But there is always err:ntdll:RtlpWaitForCriticalSection witch blocks everything.
What should I put in XXXXX place?
Solutions that not helps: TerminateThread(tha, 0), ExitProcess(0), reopen(stdin), fclose(stdin) ... Implementing own 'my_gets' function by kbhit-getch combination is good solution for xp, win7 and win8 target, but kbhit in WINE does not work.