Linux Guard Service - 杀死守护进程
杀死某个子进程
杀死守护进程的子进程后,改进程会变为僵尸进程
14087 ? Ss 0:00 ./test4-1
14088 ? S 0:00 \_ ./test4-1
14089 ? S 0:00 \_ ./test4-1
14090 ? S 0:00 \_ ./test4-1
14091 ? S 0:00 \_ ./test4-1
14092 ? S 0:00 \_ ./test4-1
14093 ? S 0:00 \_ ./test4-1
14094 ? S 0:00 \_ ./test4-1
14095 ? S 0:00 \_ ./test4-1
14096 ? S 0:00 \_ ./test4-1
14097 ? S 0:00 \_ ./test4-1
[root@localhost 04]# kill -9 14090
[root@localhost 04]# ps -xf
执行后:
14087 ? Ss 0:00 ./test4-1
14088 ? S 0:00 \_ ./test4-1
14089 ? S 0:00 \_ ./test4-1
14090 ? Z 0:00 \_ [test4-1] <defunct>
14091 ? S 0:00 \_ ./test4-1
14092 ? S 0:00 \_ ./test4-1
14093 ? S 0:00 \_ ./test4-1
14094 ? S 0:00 \_ ./test4-1
14095 ? S 0:00 \_ ./test4-1
14096 ? S 0:00 \_ ./test4-1
14097 ? S 0:00 \_ ./test4-1
[root@localhost 04]#
杀死父进程
守护进程的父进程后,僵尸进程释放,正常子进程变为正常进程
[root@localhost 04]# kill -9 14087
[root@localhost 04]# ps -xf
僵尸进程消失了
14088 ? S 0:00 ./test4-1
14089 ? S 0:00 ./test4-1
14091 ? S 0:00 ./test4-1
14092 ? S 0:00 ./test4-1
14093 ? S 0:00 ./test4-1
14094 ? S 0:00 ./test4-1
14095 ? S 0:00 ./test4-1
14096 ? S 0:00 ./test4-1
14097 ? S 0:00 ./test4-1
杀死所有进程
直接使用进程名称
pkill 进程名
让子进程随父进程一同结束
在创建进程后使用prctl,监听父进程的DEATHSIG
for (i = 0; i < 10; i++) {
sleep(3);
printf("new fork() process pid = %d \n", pid);
pid = fork();
if (pid == 0) {
prctl(PR_SET_PDEATHSIG,SIGKILL);
break;
}
}
当父进程死亡后,子进程会自动收到信号并结束,不会产生僵尸进程和孤儿进程
14508 ? Ss 0:00 ./test4-2
14509 ? S 0:00 \_ ./test4-2
14510 ? S 0:00 \_ ./test4-2
14511 ? S 0:00 \_ ./test4-2
14512 ? S 0:00 \_ ./test4-2
14513 ? S 0:00 \_ ./test4-2
14514 ? S 0:00 \_ ./test4-2
14515 ? S 0:00 \_ ./test4-2
14516 ? S 0:00 \_ ./test4-2
14517 ? S 0:00 \_ ./test4-2
14518 ? S 0:00 \_ ./test4-2
[root@localhost 04]# kill -9 14508
[root@localhost 04]# ps -xf
6786 ? S 0:00 /usr/libexec/gconfd-2
[root@localhost 04]#
[root@localhost 04]#
[root@localhost 04]#
Linux Guard Service - 杀死守护进程的更多相关文章
- Linux编程之《守护进程》
Intro ----- 守护进程,也就是通常说的Daemon进程,是Linux中的后台服务进程.它是一个生存期较长的进程,通常独立于控制终端并且周期性地执行某种任务或等待处理某些发生的事件.守护进程常 ...
- 一只简单的网络爬虫(基于linux C/C++)————守护进程
守护进程,也就是通常说的Daemon进程,是Linux中的后台服务进程.它是一个生存期较长的进程,通常独立于控制终端并且周期性地执行某种任务或等待处理某些发生的事件.守护进程常常在系统引导装入时启动, ...
- Linux Guard Service - 守护进程分裂
分裂守护进程 由于fork()后第一行仍然在循环中,使用fork()返回值鉴别当前进程的性质 int i = 0; for (i = 0; i < 10; i++) { // sleep(1); ...
- Linux Guard Service - 守护进程的作用、用途、父进程标识的特点
让test2直接成为守护进程 [root@localhost 02]# cat test2.c //test2 #include<stdio.h> #include<unistd.h ...
- Linux架构之Rsync守护进程推和拉
第三十三章 Rsync服务 33.1)Rsync基本概述 rsync是一款开源.快速.多功能.可实现全量及增量的本地或远程数据同步备份的优秀工具.rsync软件适用于Unix/linux/Window ...
- window 和 linux 环境下杀死tomcat进程——也可以解决其他端口被占用的问题
1.应用场景 在Windows或者linux操作系统中,我们在启动一个tomcat服务器时,经常会发现8080端口已经被占用的错误,而我们又不知道如何停止这个tomcat服务器. 2.window环境 ...
- Linux 下Qt实现守护进程实例(转)
原文地址:Linux守护进程的编程方法(含实例) 作者:lingdxuyan 参考文献 Linux信号列表(zz) Linux 守护进程的编程方法 linux上编写守护进程的例程 Linux下后台守 ...
- Linux系统编程之--守护进程的创建和详解【转】
本文转载自:http://www.cnblogs.com/mickole/p/3188321.html 一,守护进程概述 Linux Daemon(守护进程)是运行在后台的一种特殊进程.它独立于控制终 ...
- Linux下一个简单守护进程的实现 (Daemon)
在Linux/UNIX系统引导的时候会开启很多服务,这些服务称为守护进程(也叫Daemon进程).守护进程是脱离于控制终端并且在后台周期性地执行某种任务或等待处理某些事件的进程,脱离终端是为了避免进程 ...
随机推荐
- CFGym 101490E 题解
一.题目链接 http://codeforces.com/gym/101490 二.题面 三.题意 给你一个图,n个点,m条边,一个x,从顶点1走到顶点n.假设从顶点1走到顶点n的最短路为d,x代表你 ...
- bootstrap插件的一些常用属性介绍
1.下拉菜单 <div class="dropdown"> <button class="btn btn-default dropdown-toggle ...
- python re示例
#!/usr/bin/env python # encoding: utf-8 # Date: 2018/5/25import re s = '124311200111155214'ss = re.s ...
- [失败]SystemTap和火焰图(Flame Graph)
本文参考http://blog.51cto.com/xuclv/1184517 SystemTap简介: SystemTap provides free software (GPL) infrastr ...
- Backing up the tail
The tail of the transaction log usually refers to the contents of the database's transaction log tha ...
- OpenCL NativeKernel 计算矩阵乘法
▶ 使用函数 clEnqueueNativeKernel 来调用 C/C++ 本地函数(在 OpenCL 中将其看做回调函数),使用本地编译器(而不是 OpenCL 编译器)来编译和执行内核 ● 代码 ...
- DBNavigator中把insert变为append
procedure TForm1.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);begin if Button = nbIns ...
- maven常用命令集合
作者:ydlmlh 原文:http://ydlmlh.iteye.com/blog/2158973 抽了点时间,整理了一些maven常用命令参数,以便参考:参考了maven官网和网上其他一些maven ...
- centOs7 忘记root密码
记录:https://blog.csdn.net/niu_hao/article/details/52882895
- Apache Hive 安装文档
简介: Apache hive 是基于 Hadoop 的一个开源的数据仓库工具,可以将结构化的数据文件映射为一张数据库表, 并提供简单的sql查询功能,将 SQL 语句转换为 MapReduce 任务 ...