From 969b9f5e5d8a727e5d5588b3385967045f511e5e Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 10 Oct 2008 15:28:26 +0200 Subject: Only try to read char when POLLIN is set --- src/madc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/madc.cpp b/src/madc.cpp index 18ed477..6d4b680 100644 --- a/src/madc.cpp +++ b/src/madc.cpp @@ -61,6 +61,11 @@ static void handleCommand(char *cmd) { } } +static void charHandler(short events) { + if(events & POLLIN) + rl_callback_read_char(); +} + static void activateReadline() { if(parser->willDisconnect()) return; @@ -107,7 +112,7 @@ int main(int argc, char *argv[]) { parser = new Mad::Client::CommandParser(connection); parser->signalFinished().connect(sigc::ptr_fun(activateReadline)); - Net::FdManager::getFdManager()->registerFd(STDIN_FILENO, sigc::hide(sigc::ptr_fun(rl_callback_read_char))); + Net::FdManager::getFdManager()->registerFd(STDIN_FILENO, sigc::ptr_fun(charHandler)); activateReadline(); -- cgit v1.2.3