c语言实现查看进程是否存在
2013-04-01 10:19
489 查看
#include<unistd.h> #include<sys/types.h> #include<sys/wait.h> #include<stdio.h> #include<stdlib.h> #include<fcntl.h> #include<limits.h> #define BUFSZ 150 void err_quit(char *msg) { perror(msg); exit(EXIT_FAILURE); } int main(int argc, char *argv[]) { FILE* fp; int count; char buf[BUFSZ]; char command[150]; sprintf(command, "ps -ef | grep **** | grep -v grep | wc -l" ); if((fp = popen(command,"r")) == NULL) err_quit("popen"); if( (fgets(buf,BUFSZ,fp))!= NULL ) { count = atoi(buf); if(count == 0) printf("not found\n"); else printf("process :tdv1 total is %d\n",count); } pclose(fp); exit(EXIT_SUCCESS); }
相关文章推荐
- Linux下C语言实现查看进程是否存在
- Linux下C语言实现查看进程是否存在
- C语言实现查看进程是否存在的方法示例
- Linux下C语言实现查看进程是否存在
- Win 查看系统进程中是否已存在某个程序
- Shell实现判断进程是否存在并重新启动脚本
- 查看PID 进程是否存在的一个小技巧
- delphi中如何查看某个程序在进程中是否已经存在
- linux查看进程是否存在,不存在则重启
- shell 查看Linux 进程 是否存在
- C语言判断某进程是否存在
- Shell实现判断进程是否存在并重新启动脚本
- Shell实现判断进程是否存在并重新启动脚本分享
- 查看某个进程是否存在的脚本
- 【PAT】1083. 是否存在相等的差 (20)【C语言实现】
- Shell实现判断进程是否存在并重新启动脚本分享
- C语言判断当前某一个进程是否存在
- python 杀进程 判断文件是否存在 查看进程
- 查看是否存在tomcat进程和关闭方法
- pat乙级是否存在相等的差(c语言实现)