求助:如何在c程序中获得shell的返回值
需要获得一个进程的进程号,采用she l l 调用来完成.但是无法将匹配的数字传回C程序我的程序如下 :
#include <stdio.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
main()
{
int pid;
pid=system("ps -ef | grep linphonec|awk '{print $4}'");
printf("The pid is %d\n",pid);
} use popen
页:
[1]