appears to be oldnames64.lib pclose

Started by popeye4747, October 24, 2011, 11:33:33 PM

Previous topic - Next topic

popeye4747

Hello all:

While compiling using the latest version of Pelles C  on 64 bit Win 7, in my program I call popen,  and then pclose.
When the program runs, it quits just at the call for pclose.

I used the pelles C debugger, and this is where it appears to die, at the call to pclose.

But, if I compile 32 bit on my 64 bit system, using 64bit pelles C, then all works
and the call to popen, and pclose all works OK both on 32 bit, and when run on 64 bit.

So my logic lead to oldnames64.lib 

My question to the group is, has anyone else seen this type of problem
and if so what is the solution?

If  you need additional details, please let me know.

Other library calls in oldnames64.lib do not appear to be effected, although I have
not done any extensive testing of other calls.

Thanks for your help.

CommonTater

It would help if you posted either your active code or a smaller snippet of code that demonstrates the behavior... (be sure to use the code tags option).

If it's working as 32 bit but not working as 64 bit, I would guess it's a pointer problem of some kind...  but without seeing your code, that's just speculation.


popeye4747

int listAvailable(char *prnt)
{
    char cmdpath[LINSIZ];
    char line1[LINSIZ];
    char fileNam[128];
    char *lptr;
    char *l2ptr;
    int linecnt = 0;
    int cnt = 0;
   
    strcpy(cmdpath,cwd);
    strcat(cmdpath,"\\");
    strcat(cmdpath,"listfiles.exe");
   
    sglcnt = 0;
   
    if(pfile = _popen(cmdpath,"r"))
     {
      while(fgets(line1,LINSIZ,pfile) != NULL)
          {
           strip_newline(line1);
           
           linecnt++;
           
           
           lptr = line1;
           l2ptr = fileNam;
           while(*lptr != 32)
               {
                *l2ptr++ = *lptr++;   
               } /* End while */
               
           *l2ptr++ = '\0';
           strcpy(fileList[sglcnt++],fileNam);

           
          } /* End while */
         
     } /* End if */
     
    _pclose(pfile);
   
   
    return linecnt;
   
} /* End listAvailable */

CommonTater

pfile appears to be undefined. 
Also your if(pfile = _popen(...)) probably doesn't do quite what you expect. It's possible the file is not opening. An explicit test would be better ...

FILE* pfile

pfile = _popen(cmdpath,"r");
if (!pfile)
  return -1;      // or suitable error value


You might also try some diagnostic printf() calls in there to make sure of what it's doing. 







TimoVJL

...
           while(*lptr && *lptr != 32)
               {
                *l2ptr++ = *lptr++;   
               } /* End while */
           *l2ptr = '\0';
...
          } /* End while */
          _pclose(pfile);
     } /* End if */
...
May the source be with you