From: Henry N. <Hen...@Ar...> - 2008-05-10 14:11:30
|
Paolo Minazzi schrieb: > Hi, > yesterday I have tried a little to understand the problem of no-input of Vista. > I have only tried CONSOLE-NT and what I write below is about console-nt. > I have written a small program > > int pid; > > int main() > { > pid=fork(); > if (pid==0) > { > while (1) printf("X"); > } > else > { > char c[1024]; > read(1,c,1); > kill(pid,9); > } > } Thanks for the code example. Seen from your other mail, this is: read(STDIN_FILENO,c,1); > > Under XP is Ok. > If I press ENTER the father kill the child. > > Under Vista it does not work because the daemon (I think ...) doesn't > get the input. > Under Vista it doesn't get neither CTRL-C nor any input. It is a > general input problem. > If I insert a usleep in this way : > > while(1) > { > printf("X"); > usleep(100); > } > > then under Vista all is OK. > An oher way to make OK under Vista is removing usleep(....) and add > fflush(stdout); > > If there is a very important output on the console-nt Vista doesn't > get any input ! > > I have tried to understand the code, but I don't understand well the code. > I have seen the widget->loop() that check if there is some input event. > But I don't understand where is managed the console output. I think > with the reactor callback or something else. Console input is handled by "console_widget_NT_t::loop()". The keyboard will be read with "ReadConsoleInput(input, &i, 1, &r)". src/colinux/os/winnt/user/console-nt/widget.cpp:437 http://colinux.svn.sourceforge.net/viewvc/colinux/branches/devel/src/colinux/os/winnt/user/console-nt/widget.cpp?view=markup The output is handled by "console_window_t::event". and forwarded to "co_rc_t console_widget_t::event(co_console_message_t *message)" src/colinux/user/console-base/widget.cpp:40 http://colinux.svn.sourceforge.net/viewvc/colinux/branches/devel/src/colinux/user/console-base/widget.cpp?revision=710&view=markup Ok, lets see how the reactor works on an endless output. In normal case the reactor select leave 1ms after no output to handle inputs. co_reactor_select will also leave after every output, so the "console_window_t::loop" will be enter again every very fast and should check the input from keyboard. The question is: What gets "GetNumberOfConsoleInputEvents" in "console_widget_NT_t::loop()", on very fast output and you pressed the enter key? I have no Vista. Paolo, can you change the code and check with colinux-debug-daemon? For example with some "Trace" debugs in the code of src/colinux/os/winnt/user/console-nt/widget.cpp: co_rc_t console_widget_NT_t::loop() { DWORD r; if (!GetNumberOfConsoleInputEvents(input, &r)) { co_debug("GetNumberOfConsoleInputEvents failed with %d", GetLastError()); // Trace return CO_RC(ERROR); } if (r == 0) { co_debug("GetNumberOfConsoleInputEvents nothing"); // Trace return CO_RC(OK); } INPUT_RECORD i; ReadConsoleInput(input, &i, 1, &r); if (ctrl_exit) { window->detach(); return CO_RC(OK); } switch ( i.EventType ) { case KEY_EVENT: co_debug("ReadConsoleInput KEY_EVENT: process_key_event"); // Trace process_key_event(i.Event.KeyEvent); break; case FOCUS_EVENT: /* MSDN says this events should be ignored ??? */ process_focus_event(i.Event.FocusEvent); break; case MOUSE_EVENT: /* *TODO: must be enabled first also */ break; default: co_debug("GetNumberOfConsoleInputEvents unhandled event %d", i.EventType); // Trace } return CO_RC(OK); } -- Henry N. |