这么诡异,你popen怎么写的,看看
printf("\nwaiting...(thread id : %ld)\n", pthread_self());
pthread_mutex_lock(&mutex);
printf("\nenter.(thread id : %ld)\n", pthread_self());
FILE *cmd_fd = popen(cmd_str, "r");
if (cmd_fd) {
printf("\ncmd running....\n");
}
printf("\nexit.(thread id : %ld)\n", pthread_self());
pthread_mutex_unlock(&mutex);
@atomic_weapon:
popen将cmd_str命令的标准输出dup到管道,需要标准I/O来读取命令打印的信息,结束了之后用pclose关闭,而不是用fclose关闭。