C
codefixer
Hi,
I have a situation where I have to handle the following scenario.
The main() must wait for child to complete or the main() must kill the
child after 3 seconds and exit.
/* Assume everythign is declared */
time(&start);
while ( childpid != wait(&status) )
{
time(&end);
diff = difftime(end,start);
fprintf(stderr, "\n%ld",diff);
if (diff >= 3.00)
{
/* Kill child */
exit(0);
}
}
}
Even though the child is taking more than 3 seconds, this doesn't seem
to work. Any idea why ?
Thanks.
I have a situation where I have to handle the following scenario.
The main() must wait for child to complete or the main() must kill the
child after 3 seconds and exit.
/* Assume everythign is declared */
time(&start);
while ( childpid != wait(&status) )
{
time(&end);
diff = difftime(end,start);
fprintf(stderr, "\n%ld",diff);
if (diff >= 3.00)
{
/* Kill child */
exit(0);
}
}
}
Even though the child is taking more than 3 seconds, this doesn't seem
to work. Any idea why ?
Thanks.