setting new polling frequency -- maybe we should make it as parameter
[runfinite.git] / src / main.cpp
index d6d5692f9dd07d52960464f5541028fd49ced05d..c4648804283ad1d83e6a8990ddb1db6f58320a6a 100644 (file)
@@ -181,12 +181,14 @@ int main(int argc, char** argv)
                //Nmb of loops=seconds
                float loops=0;          
                //Status flags of child process 
-               int status, w;
+               int status;
+               //granularity
+               const int ussleep=25000;
 
-               do
+               while(true)
                {
                        //Kill the child
-                       if( loops >= maxtime )
+                       if( loops*ussleep/1e6 >= maxtime )
                        {
                                if( argVerbose )
                                        printf("Kill child...\n");
@@ -195,15 +197,18 @@ int main(int argc, char** argv)
                                        break;
                        }
 
-                       //Sleep a round
-                       sleep(1);
-                       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++;                        
+
+               }
        }