I have a cpp code that I'm trying to run with faketime command. I'm running it on two identical computers. They're both running RHEL 7. I noticed that when I run my code, on one computer, it totally skips my popen call.
My code is essentially
char ntp[]= "192.168.1.200";
FILE *jitter;
char line[100];
char *start;
char * eol;
char pps[] = "NTPS";
jitter = popen("chronyc sources", "r");
int i;
cout<<"reached here"<<endl;
while(fgets(line,sizeof(line),jitter))
{
cout<<"line is\n"<<line<<endl;
if(strstr(line,pps)){
start = strpbrk(line,"#0+-");
cout<<"PPS is "<<start<<endl;
//find new line character and replace it with comma
eol = strrchr(start,'\n');
i=eol-start;
start[i]=',';
myfile<<start;
}
if(strstr(line,ntp)){
myfile<<start;
}
}
pclose(jitter);
}
I added a print statement of
cout<<"reached here"<<endl;
but when I run it with "faketime 'last friday 5pm' ./code", on one computer it never reaches the print statement for some reason while on the other it does. I searched online to no success (I'm not running a approximating algorithm, they have the same compiler and make file, etc. I'm literally doing a git pull of the code and running it).
Does anyone know why?
Thanks