当前位置:网站首页>IO process thread -> process -> day4
IO process thread -> process -> day4
2022-08-02 08:21:00 【Call me to take care of the sea QAQ】
Table of Contents
Exercise
1. Create an orphan process
2. Create a zombie process
First, orphan process
It means that only the child process is still executing, the parent process has ended, and the parent process number is 1.
1.1 Orphan Function
#include #include #include int main(int argc, const char *argv[]){pid_t pid=fork();if(0 == pid){while(1){printf("Orphan Process\n");sleep(1);}}else if(pid > 0){sleep(2);}else{perror("fork");}return 0;} 1.2 Execution Result
ps -ajx View Linux process information

2. ZombiesProcess
That is, the parent process is still executing, and the child process has ended, but the parent process has not collected the body of the process.
2.1 Zombie function
#include #include #include int main(int argc, const char *argv[]){pid_t pid=fork();if(0 == pid){sleep(2);}else if(pid > 0){while(1){printf("Zombie process\n");sleep(1);}}else{perror("fork");}return 0;} 2.2 Execution Result
ps -ajx View Linux process information

边栏推荐
猜你喜欢
随机推荐
基本SQL语句(一篇就够了)
flutter解决键盘和输入框不适配问题
按键控制流水灯(计时器)
Xilinx Constraint Study Notes - Timing Constraints
小说里的编程 【连载之二十三】元宇宙里月亮弯弯
@FeignClient configuration参数配置
HCIP9_BGP增加实验
MFC最详细入门教程[转载]
.NET静态代码织入——肉夹馍(Rougamo) 发布1.1.0
Elasticserch 自定义字段,用户会频繁的创建和删除字段,怎么设计mapping?
MySQL - Detailed Explanation of Database Transactions
7.联合索引(最左前缀原则)
【Unity3D】初学加密技巧(反破解)
如何开启mysql慢查询日志?
playwright 爬虫使用
UG NX二次开发(C#)-外部模式-导出dwg格式的文件
WebGPU 导入[2] - 核心概念与重要机制解读
HCIP 第四天
替换ptmalloc,使用tcmalloc和jemalloc
CASA模型、CENTURY模型应用与案例分析









