From 2daaae1fdf21c263ae1a64b89b6a6092a814b1e6 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Sat, 26 Apr 2008 10:27:26 +0200 Subject: [PATCH] improved performance very fast terminating commands --- src/main.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c9caf6e..345c5d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -183,9 +183,9 @@ int main(int argc, char** argv) //Status flags of child process int status; //100ms granularity - const int ussleep=50000; + const int ussleep=100000; - do + while(true) { //Kill the child if( loops*ussleep/1e6 >= maxtime ) @@ -197,15 +197,18 @@ int main(int argc, char** argv) break; } - //Sleep a round - usleep(ussleep); - loops++; - //Test for child if( waitpid(-1, &status, WNOHANG | WUNTRACED | WCONTINUED) < 0 ) break; - }while( !WIFEXITED(status) ); + if( WIFEXITED(status) ) + break; + + //Sleep a round + usleep(ussleep); + loops++; + + } } -- 2.30.2