Why not simple just sleep for N
seconds, then do the measure
call? If you install a SIGCHLD
handler to catch when the child process exits, then e.g. sleep
will be interrupted and return the number of seconds left.
Something like
signal(SIGCHLD, sigchld_handler);
do
{
measure();
} while (sleep(N) == 0);
waitpid(...);