A
anuragmenon
Hello,
Trying to debug a weird problem here. When I run this program many
times over, at some point argc gets corrupted and I get the error that
enough number of arguments are not provided. It definitely seems to
have something to do with the env. variable being set and used because
the previous version of this code did not have that variable and did
not have this problem. I am running this on linux on a powerpc based
hardware. stdlib.h is included.
My condition is that if this env variable does not exist at all or if
it exisits and it is set to 1, I want to <DO STUFF> and if it exisits
and is set to 0, <DO NOT DO STUFF>
Here is the relevant portion of the program I am trying to debug. .
int main(int argc, char** argv) {
char* status = 0;
if(argc < 2)
{
fprintf(stderr, " Not enough arguments.\n");
fflush(stderr);
}
while(1)
{
status = getenv("TIMER_STATUS");
if((status == 0) || ((status != 0) && (atoi(status) != 1)))
{
<Do STUFF>
}
else
{
<DO NOT STUFF>
}
}
In MOST cases, the program runs just fine. But after about 10-15 times
of running repeatedly, i will always get the error that there are not
enough arguments. If I reboot the entire board that will restart the
kernel and everything, all is well once again until we get into that
restarting many times scenario.
Any ideas of where I might start to debug this?
Thanks much,
Vinod
Trying to debug a weird problem here. When I run this program many
times over, at some point argc gets corrupted and I get the error that
enough number of arguments are not provided. It definitely seems to
have something to do with the env. variable being set and used because
the previous version of this code did not have that variable and did
not have this problem. I am running this on linux on a powerpc based
hardware. stdlib.h is included.
My condition is that if this env variable does not exist at all or if
it exisits and it is set to 1, I want to <DO STUFF> and if it exisits
and is set to 0, <DO NOT DO STUFF>
Here is the relevant portion of the program I am trying to debug. .
int main(int argc, char** argv) {
char* status = 0;
if(argc < 2)
{
fprintf(stderr, " Not enough arguments.\n");
fflush(stderr);
}
while(1)
{
status = getenv("TIMER_STATUS");
if((status == 0) || ((status != 0) && (atoi(status) != 1)))
{
<Do STUFF>
}
else
{
<DO NOT STUFF>
}
}
In MOST cases, the program runs just fine. But after about 10-15 times
of running repeatedly, i will always get the error that there are not
enough arguments. If I reboot the entire board that will restart the
kernel and everything, all is well once again until we get into that
restarting many times scenario.
Any ideas of where I might start to debug this?
Thanks much,
Vinod