projects
/
runfinite.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changing sleep to usleep for higher responsivness
[runfinite.git]
/
src
/
main.cpp
diff --git
a/src/main.cpp
b/src/main.cpp
index 5b1ca074fb3c2da93178d3357c09b53f9df382fd..c9caf6e6e9def5691f51210495500c92c5a0f02f 100644
(file)
--- a/
src/main.cpp
+++ b/
src/main.cpp
@@
-1,3
+1,12
@@
+/**
+ * shuber, 2008-04-24
+ *
+ * Little hack to let a process run only a specific amount of time. If process
+ * has not finished until that amount of time it is killed.
+ *
+ */
+
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@
-172,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=50000;
do
{
//Kill the child
do
{
//Kill the child
- if( loops >= maxtime )
+ if( loops
*ussleep/1e6
>= maxtime )
{
if( argVerbose )
printf("Kill child...\n");
{
if( argVerbose )
printf("Kill child...\n");
@@
-187,7
+198,7
@@
int main(int argc, char** argv)
}
//Sleep a round
}
//Sleep a round
-
sleep(1
);
+
usleep(ussleep
);
loops++;
//Test for child
loops++;
//Test for child