X-Git-Url: http://git.sthu.org/?a=blobdiff_plain;f=src%2Fmain.cpp;h=345c5d379a248cd9bc686610cedc8dbd3f5cf47e;hb=2daaae1fdf21c263ae1a64b89b6a6092a814b1e6;hp=d6d5692f9dd07d52960464f5541028fd49ced05d;hpb=89191acb4dea4fda07d66e5ffd3cda1df229e581;p=runfinite.git diff --git a/src/main.cpp b/src/main.cpp index d6d5692..345c5d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; + //100ms granularity + const int ussleep=100000; - 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++; + + } }