Linux下一个进程重启自己的简单实现
2017-10-12 20:17
525 查看
#include
#include
#include
#include
#include
int main(int argc, char* argv[])
{
int fd = open("tmp.txt", O_CREAT | O_APPEND | O_RDWR, 0666);
char buf[] = "hello huang jia jia\n";
write(fd, buf, sizeof(buf));
close(fd);
sleep(8);
if(fork() == 0)
{
if(execl("a.out", NULL) < 0)
{
perror("Execl:");
}
}
return 0;
}
关闭进程命令:ps l | grep out | grep -v grep | cut -d' ' -f6 | xargs kill -9
#include
#include
#include
#include
int main(int argc, char* argv[])
{
int fd = open("tmp.txt", O_CREAT | O_APPEND | O_RDWR, 0666);
char buf[] = "hello huang jia jia\n";
write(fd, buf, sizeof(buf));
close(fd);
sleep(8);
if(fork() == 0)
{
if(execl("a.out", NULL) < 0)
{
perror("Execl:");
}
}
return 0;
}
关闭进程命令:ps l | grep out | grep -v grep | cut -d' ' -f6 | xargs kill -9
相关文章推荐
- linux 进程监控和自动重启的简单实现 .
- Linux下一个简单守护进程的实现 (Daemon)
- linux 进程监控和自动重启的简单实现
- linux 进程监控和自动重启的简单实现
- linux 进程监控和自动重启的简单实现
- Linux下一个简单守护进程的实现 (Daemon)
- Linux下一个简单守护进程的实现 (Daemon)
- Linux下一个简单守护进程的实现 (Daemon)
- Linux 简单shell创建自己的守护进程,自动重启,纪录进程运行状态,日志切割压缩
- linux 进程监控和自动重启的简单实现
- demopu教你学linux,shell实现简单的进程监控脚本
- Linux下一个简单线程池实现的源码注释
- python实现linux下的简单进程监控
- Linux下一些文件操作和一些简单命令的自己实现
- 学习笔记☞Linux常用命令【三】 ( 简单shell编程,管道,重定向,输出,进程,网络管理,关机重启)
- linux进程监控与自动重启实现
- Linux 下实现进程退出后自动重启
- linux脚本实现监控某个进程并重启
- Linux下一个简单的日志系统的设计及其C代码实现
- Linux下一个简单的日志系统的设计及其C代码实现