From 47e9a7b6a10f757e6cfb8f86a25a18a16a8a787f Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Sat, 27 Apr 2013 00:43:42 +0200 Subject: [PATCH] Fix :D --- src/API/ConsoleAPI.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php index b7b0756d..5bdcc5ca 100644 --- a/src/API/ConsoleAPI.php +++ b/src/API/ConsoleAPI.php @@ -262,24 +262,28 @@ class ConsoleLoop extends Thread{ $line = trim(fgets($fp)); if($line != ""){ $this->line = $line; - $this->wait(); - $this->line = false; } } public function run(){ + $fp = fopen("php://stdin", "r"); if(HAS_EVENT){ $this->base = new EventBase(); - $this->ev = new Event($this->base, STDIN, Event::READ | Event::PERSIST, array($this, "readLine")); + $this->ev = new Event($this->base, $fp, Event::READ | Event::PERSIST, array($this, "readLine")); $this->ev->add(); - $this->base->loop(); - }else{ - $fp = fopen("php://stdin", "r"); + while($this->stop === false){ + $this->base->loop(EventBase::LOOP_ONCE); + if($this->line !== false){ + $this->wait(); + $this->line = false; + } + } + }else{ while($this->stop === false){ $this->readLine($fp); } - @fclose($fp); } + @fclose($fp); exit(0); } }