Linux开发

推荐列表 站点导航

当前位置:首页 > 服务器技术 > Linux开发 >

Linux C语言检查进程是否存在

来源:互联网  作者:网友投稿  发布时间:2021-01-06 21:53
使用C语言根据进程名检查进程是否存在,然后重启进程。 /* * COPYRIGHT NOTICE * Copyright (C) 2016 HuaHuan Electronics Corporation...

Inc. All rights reserved * * Author :Kevin_fzs * File Name:/home/kevin/works/projects/MIPS53003/drivers/webRestart.c * Create Date :2016/11/16 15:11 * Last Modified:2016/11/16 15:11 * Description : */ #include stdio.h #include stdlib.h #include string.h int getRestartStatus() { char *name=/home/webserver/Rflag.txt; FILE *fd; int ret=0; fd = fopen(name, r))==NULL) { printf(popen err\n); continue; } memset(buf。

0,ptr))!= NULL) //获取进程和子进程的总数 { count = atoi(buf); if(count = 0) //当进程数小于等于0时, sizeof(buf)); if((fgets(buf,然后重启进程,说明进程不存在 { system(/home/appweb_start.sh); printf(restart appweb \n); } } } usleep(200000); , r); if(NULL == fd) return 1; else return 0; } int main() { FILE *ptr = NULL; char cmd[128] = ps -ef | grep appweb | grep -v grep | wc -l; int status = 0; char buf[150]; int count; while(1) { status = getRestartStatus(); //根据标志文件来决定是否要检查进程 if(status) { if((ptr = popen(cmd, 使用C语言根据进程名检查进程是否存在, sizeof(buf), /* * COPYRIGHT NOTICE * Copyright (C) 2016 HuaHuan Electronics Corporation,。

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/server/kaifa/11620.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

Linux C语言检查进程是否存在

2021-01-06 编辑:网友投稿

Inc. All rights reserved * * Author :Kevin_fzs * File Name:/home/kevin/works/projects/MIPS53003/drivers/webRestart.c * Create Date :2016/11/16 15:11 * Last Modified:2016/11/16 15:11 * Description : */ #include stdio.h #include stdlib.h #include string.h int getRestartStatus() { char *name=/home/webserver/Rflag.txt; FILE *fd; int ret=0; fd = fopen(name, r))==NULL) { printf(popen err\n); continue; } memset(buf。

0,ptr))!= NULL) //获取进程和子进程的总数 { count = atoi(buf); if(count = 0) //当进程数小于等于0时, sizeof(buf)); if((fgets(buf,然后重启进程,说明进程不存在 { system(/home/appweb_start.sh); printf(restart appweb \n); } } } usleep(200000); , r); if(NULL == fd) return 1; else return 0; } int main() { FILE *ptr = NULL; char cmd[128] = ps -ef | grep appweb | grep -v grep | wc -l; int status = 0; char buf[150]; int count; while(1) { status = getRestartStatus(); //根据标志文件来决定是否要检查进程 if(status) { if((ptr = popen(cmd, 使用C语言根据进程名检查进程是否存在, sizeof(buf), /* * COPYRIGHT NOTICE * Copyright (C) 2016 HuaHuan Electronics Corporation,。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/server/kaifa/11620.shtml

相关文章

风云图片

推荐阅读

返回Linux开发频道首页