void *SC_TerminalClient::readlineFunc( void *arg ) { readlineInit(); SC_TerminalClient *client = static_cast<SC_TerminalClient*>(arg); HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE); HANDLE hnds[] = { client->mQuitInputEvent, hStdIn }; bool shouldRun = true; while (shouldRun) { DWORD result = WaitForMultipleObjects( 2, hnds, false, INFINITE ); if( result == WAIT_FAILED ) { postfl("readline: wait error.\n"); client->onQuit(1); break; } int hIndex = result - WAIT_OBJECT_0; if( hIndex == 0 ) { postfl("readline: quit requested.\n"); break; } if( hIndex == 1 ) { rl_callback_read_char(); } } postfl("readline: stopped.\n"); return NULL; }
void *SC_TerminalClient::readlineFunc( void *arg ) { readlineInit(); SC_TerminalClient *client = static_cast<SC_TerminalClient*>(arg); fd_set fds; FD_ZERO(&fds); while(true) { FD_SET(STDIN_FD, &fds); FD_SET(client->mInputCtlPipe[0], &fds); if( select(FD_SETSIZE, &fds, NULL, NULL, NULL) < 0 ) { if( errno == EINTR ) continue; postfl("readline: select() error:\n%s\n", strerror(errno)); client->onQuit(1); break; } if( FD_ISSET(client->mInputCtlPipe[0], &fds) ) { postfl("readline: quit requested\n"); break; } if( FD_ISSET(STDIN_FD, &fds) ) { rl_callback_read_char(); } } postfl("readline: stopped.\n"); return NULL; }
void SC_TerminalClient::inputThreadFn() { #if HAVE_READLINE if (mUseReadline) readlineInit(); #endif startInputRead(); boost::asio::io_service::work work(mInputService); mInputService.run(); }