Home > Back-end >  Popen use ping 127.0.0.1 -t pclose cannot close
Popen use ping 127.0.0.1 -t pclose cannot close

Time:09-19

When I'm CMD command is ping 127.0.0.1 -t command, pclose cannot close, always return 0 or print over string
Int execmd (char * CMD, char * result)
{
Char buffer [128].
int i=0;
The FILE * pipe=_popen (CMD, "r");//open, and execute the command
if (! Pipe)
return 1;//return 1 said running failure

while(! The feof (pipe))
{
If (the fgets (buffer, 128, pipe))//will be output to the result of
{
Strcat (result, buffer);
If (i<5)
{
i=i+1;
}
If (i>
=5){
break;
}
}
}
_pclose (pipe);//close
Printf (" over \ n ");
return 0;
}
  • Related