//Status flags of child process
int status;
//100ms granularity
- const int ussleep=50000;
+ const int ussleep=100000;
- do
+ while(true)
{
//Kill the child
if( loops*ussleep/1e6 >= maxtime )
break;
}
- //Sleep a round
- usleep(ussleep);
- 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++;
+
+ }
}