Dear ROOTers,
I am running a process (SPheno) that may hang, and thus would like to kill it when it uses more than a certain amount of time. I have written the following code:
int pid;
double lasttime=0;
if( (pid = fork()) == 0 ){
system("./SPheno LesHouches.in");
}
else{
TStopwatch timer;
timer.Start(1);
while (1) {
double t = timer.RealTime();
if( t > lasttime ) lasttime = t;
if( lasttime > 2 ) {
TThread::Kill( pid );
cout << "Killing process.." << endl;
}
timer.Start(0);
}
timer.Stop();
}
‘Lasttime’ should help me in estimating the average time needed by the process when it does not hang.
But the quantity ‘lasttime’ is always zero at the end. I think I must be mishandling something, do you see what is wrong ?
Thanks in advance,
cheers,
Xavier