Changeset 13177


Ignore:
Timestamp:
Nov 8, 2009, 10:27:07 PM (10 years ago)
Author:
gb
Message:

PeekNamedPipe?() isn't detecting EOF on Win7, so do a timed wait for
the parent process handle to be signaled (rather than just sleeping)
to detect termination.

When reading console input, don't do a blocking read when a key event
is detected unless that key event produces a character. (Win7 at least
seems to report things like shift-key events.)

Dear god windows sucks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/aux/cocotron/win32/cocotron/WaltConsole/WaltConsole.c

    r12824 r13177  
    7373      for (i = 0; i < ninput_events; i++) {
    7474        PeekConsoleInput(input, &ir, 1, &n);
    75         if ((ir.EventType == KEY_EVENT)) {
     75        if ((ir.EventType == KEY_EVENT) &&
     76            (ir.Event.KeyEvent.uChar.UnicodeChar != 0)) {
    7677          if (!ReadFile(input, buf, sizeof(buf), &nread, NULL)) {
    7778            return -1;
     
    132133  in = GetStdHandle(STD_INPUT_HANDLE);
    133134  out = GetStdHandle(STD_OUTPUT_HANDLE);
     135  ppid = getppid();
     136  hppid = OpenProcess(PROCESS_QUERY_INFORMATION|SYNCHRONIZE,FALSE,ppid);
    134137
    135138  while (1) {
     
    141144      break;
    142145    }
    143     Sleep(100);
     146    if (WaitForSingleObject(hppid,100)==WAIT_OBJECT_0) {
     147      exit(0);
     148    }
    144149  }
    145150
     
    149154  conout = CreateFileA("CONOUT$",GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
    150155
    151   ppid = getppid();
    152156  procname = parent_process_name(ppid);
    153   hppid = OpenProcess(PROCESS_QUERY_INFORMATION|SYNCHRONIZE,FALSE,ppid);
    154157  if (!procname) {
    155158    procname = "<Unknown>";
Note: See TracChangeset for help on using the changeset viewer.