linux - Arm platform, Why the thread was blocked in popen function? -


in program, there thread calls popen function execute ping command. after letting run few days, thread block in popen. found information popen, can not result.

below output of run.

normal:

test popen before
test fgets before
test fgets after

block:

test popen before

code:

int ping_fun(char *p_ip_addr) {     file *ptr = null;     char buff[512];     char ps[128];     int ret_value = 0;       memset(buff, 0, sizeof(buff));     memset(ps, 0, sizeof(ps));      sprintf(ps,"ping -c 5 %s 2>&1 | grep -c '64 bytes from'", p_ip_addr);      printf("test popen before\n");     ptr = popen(ps, "r");      if (null != ptr)     {         printf("test fgets before\n");         fgets(buff, 512, ptr);         printf("test fgets after\n");         ret_value = atoi(buff);         if (ret_value > 0)  //ping success         {             //do .....         }         pclose(ptr);     }     else     {         printf("test popen fail\n");     } } 


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -