+/**
+ * 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>
//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
- if( loops >= maxtime )
+ if( loops*ussleep/1e6 >= maxtime )
{
if( argVerbose )
printf("Kill child...\n");
}
//Sleep a round
- sleep(1);
+ usleep(ussleep);
loops++;
//Test for child