dedicated.c
changeset 1114 74e602e41692
parent 1109 ecb98f43ba2c
child 1290 7fbc2fdfa203
equal deleted inserted replaced
1113:da5c5c571541 1114:74e602e41692
    87 	signal(sig, DedicatedSignalHandler);
    87 	signal(sig, DedicatedSignalHandler);
    88 }
    88 }
    89 #endif
    89 #endif
    90 
    90 
    91 #ifdef WIN32
    91 #ifdef WIN32
       
    92 #include <time.h>
    92 HANDLE hEvent;
    93 HANDLE hEvent;
    93 static HANDLE hThread; // Thread to close
    94 static HANDLE hThread; // Thread to close
    94 static char _win_console_thread_buffer[200];
    95 static char _win_console_thread_buffer[200];
    95 
    96 
    96 /* Windows Console thread. Just loop and signal when input has been received */
    97 /* Windows Console thread. Just loop and signal when input has been received */
   102 	}
   103 	}
   103 }
   104 }
   104 
   105 
   105 void CreateWindowsConsoleThread(void)
   106 void CreateWindowsConsoleThread(void)
   106 {
   107 {
       
   108 	static char tbuffer[9];
   107 	/* Create event to signal when console input is ready */
   109 	/* Create event to signal when console input is ready */
   108 	hEvent = CreateEvent(NULL, false, false, "keyboard input");
   110 	hEvent = CreateEvent(NULL, false, false, _strtime(tbuffer));
       
   111 	if (hEvent == NULL)
       
   112 		error("Cannot create console event!");
   109 
   113 
   110 	hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CheckForConsoleInput, 0, 0, NULL);
   114 	hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CheckForConsoleInput, 0, 0, NULL);
   111 	if (hThread == NULL)
   115 	if (hThread == NULL)
   112 		error("Cannot create console thread!");
   116 		error("Cannot create console thread!");
   113 
   117 
   115 }
   119 }
   116 
   120 
   117 void CloseWindowsConsoleThread(void)
   121 void CloseWindowsConsoleThread(void)
   118 {
   122 {
   119 	CloseHandle(hThread);
   123 	CloseHandle(hThread);
       
   124 	CloseHandle(hEvent);
   120 	DEBUG(misc, 0) ("Windows console thread shut down...");
   125 	DEBUG(misc, 0) ("Windows console thread shut down...");
   121 }
   126 }
   122 
   127 
   123 #endif
   128 #endif
   124 
   129