projects
/
runfinite.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
improved performance very fast terminating commands
[runfinite.git]
/
src
/
main.cpp
diff --git
a/src/main.cpp
b/src/main.cpp
index d6d5692f9dd07d52960464f5541028fd49ced05d..345c5d379a248cd9bc686610cedc8dbd3f5cf47e 100644
(file)
--- 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
//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
{
//Kill the child
- if( loops >= maxtime )
+ if( loops
*ussleep/1e6
>= maxtime )
{
if( argVerbose )
printf("Kill child...\n");
{
if( argVerbose )
printf("Kill child...\n");
@@
-195,15
+197,18
@@
int main(int argc, char** argv)
break;
}
break;
}
- //Sleep a round
- sleep(1);
- loops++;
-
//Test for child
if( waitpid(-1, &status, WNOHANG | WUNTRACED | WCONTINUED) < 0 )
break;
//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++;
+
+ }
}
}