I'm using the times() function to measure the value but I'm not sure if my approach is correct. Please have a look and advice
struct tms tms_start, tms_end;
if (!(pid=fork()))
{
//some necessary operations here
times(&tms_start);
execl(...);
}
else if (pid)
{
//in parent
int status;
wait(&status);
times(&tms_end);
if (WIFEXITED(status))
{
if(WEXITSTATUS(status)==0)
{
clock_t real = tms_end.tms_cstime - tms_start.tms_stime
float running_time = real/(double)sysconf(_SC_CLK_TK);
}
}
}