当前位置:网站首页>IO进程线程->进程->day4
IO进程线程->进程->day4
2022-08-02 07:39:00 【鲸叫我照顾海QAQ】
目录
练习
1.创建一个孤儿进程
2.创建一个僵尸进程
一、孤儿进程
就是只有子进程还在执行,父进程已经结束,父进程号为1。
1.1 孤儿函数
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, const char *argv[])
{
pid_t pid=fork();
if(0 == pid)
{
while(1)
{
printf("孤儿进程\n");
sleep(1);
}
}
else if(pid > 0)
{
sleep(2);
}else
{
perror("fork");
}
return 0;
}
1.2 执行结果
ps -ajx 查看Linux进程的信息

二、僵尸进程
就是父进程还在执行,子进程已经结束,但是父进程没有给该进程收尸。
2.1 僵尸函数
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, const char *argv[])
{
pid_t pid=fork();
if(0 == pid)
{
sleep(2);
}
else if(pid > 0)
{
while(1)
{
printf("僵尸进程\n");
sleep(1);
}
}else
{
perror("fork");
}
return 0;
} 2.2 执行结果
ps -ajx 查看Linux进程的信息

边栏推荐
猜你喜欢
![MySQL error 1055 solution: [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains](/img/aa/ab58ec47bb96df803dbc6a8ff6dde3.png)
MySQL error 1055 solution: [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains
![[Unity3D] Beginner Encryption Skills (Anti-Cracking)](/img/07/4a0731dd66b058c07d6240ffd36eea.png)
[Unity3D] Beginner Encryption Skills (Anti-Cracking)

Inverter insulation detection detection function and software implementation

有点奇怪!访问目的网址,主机能容器却不行

ROS文件系统以及相关命令

Database Plus 的云上之旅:SphereEx 正式开源 ShardingSphere on Cloud 解决方案

论文理解:“Cross-Scale Residual Network: A GeneralFramework for Image Super-Resolution,Denoising, and “

PLSQL Developer安装和配置

HCIP 第六天

Azure Synapse Analytics上创建用户并赋予权限
随机推荐
Data Middle Office: Started in Ali, Prosperous in DaaS
MySQL压缩包方式安装,傻瓜式教学
DeadLock的可视化分析
多版本node的安装与切换详细操作
[Unity3D] Beginner Encryption Skills (Anti-Cracking)
HCIP第三天
MySQL常见索引类型
59: Chapter 5: Develop admin management services: 12: MongoDB usage scenarios; (non-core data, non-core data with a relatively large amount of data, small private files such as face photos;)
我与csdn
通过建立新的SaaS业务来推动增长的六种方法
MPLS和BGP的综合实验
UG NX二次开发(C#)-外部模式-导出dwg格式的文件
postgres 水平分表,自动创建分区,按时间分表
Mysql error 2003 solution Can 't connect to Mysql server on' localhost '(10061).
Mysql各个大版本之间的区别
MySQL - Index Optimization and Query Optimization
18、优化网站性能
Probability Theory and Mathematical Statistics
学习笔记(8)DOM
HCIP 第九天