3 lines of code that crashes after a while

i've set up a timer that execute those 3 lines of code every time it expire (10 seconds intervals). When i let the code run for about 4-5 hour, it crashes, but im clueless has to why it does so. cmdOutput is a FILE*

cmdOutput = popen("ftpwho -v", "r");
char buff[2];
int a = fread(buff, sizeof(char), 1, cmdOutput);

There is nothing else in my code. Just that and the timer and if i comment out the lines above and let only the timer execute, it run fine for days.

could someone point some clues?

Comments

  • : i've set up a timer that execute those 3 lines of code every time it expire (10 seconds intervals). When i let the code run for about 4-5 hour, it crashes, but im clueless has to why it does so. cmdOutput is a FILE*
    :
    : cmdOutput = popen("ftpwho -v", "r");
    : char buff[2];
    : int a = fread(buff, sizeof(char), 1, cmdOutput);
    :
    : There is nothing else in my code. Just that and the timer and if i comment out the lines above and let only the timer execute, it run fine for days.
    :
    : could someone point some clues?
    :

    A process is only allowed to have so many open file descriptors.
    Since you're not calling pclose() for each time you're calling
    popen(), it's only a matter of time before you hit the limit.

    Flatline
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion