improved performance very fast terminating commands
authorStefan Huber <shuber2@gmail.com>
Sat, 26 Apr 2008 08:27:26 +0000 (10:27 +0200)
committerStefan Huber <shuber2@gmail.com>
Sat, 26 Apr 2008 08:27:26 +0000 (10:27 +0200)
src/main.cpp

index c9caf6e6e9def5691f51210495500c92c5a0f02f..345c5d379a248cd9bc686610cedc8dbd3f5cf47e 100644 (file)
@@ -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++;                        
+
+               }
        }