当前位置:网站首页>【学习笔记】进程创建
【学习笔记】进程创建
2022-07-28 05:25:00 【踏流星】
#include <stdio.h>
#include <unistd.h>
int pipeline_child()
{
printf("child PPID:%d,PID:%d\n", getppid(), getpid());
while(1);
return 0;
}
int pipeline_father()
{
printf("father PPID:%d,PID:%d\n", getppid(), getpid());
while(1);
return 0;
}
int main()
{
pid_t pid = fork();
if (pid == -1) {
printf("failed process!\n");
return -1;
}
//子进程
if(pid == 0) {
printf("child process!\n");
printf("child PPID:%d,PID:%d\n", getppid(), getpid());
pipeline_child();
} else {
//父进程
sleep(1);
printf("father process!\n");
printf("father PPID:%d,PID:%d\n", getppid(), getpid());
pipeline_father();
}
return 0;
}
边栏推荐
猜你喜欢

Surge impact immunity experiment (surge) -emc series Hardware Design Notes 6

EfficientNET_V1

set_clock_groups

Transformer self attention mechanism and complete code implementation

VS Code 基础配置与美化

Detailed explanation of creepage distance and electrical clearance

set_ false_ path

Low power design -power switch

【YOLOv5】环境搭建:Win11 + mx450

雷达成像 Matlab 仿真 2 —— 脉冲压缩与加窗
随机推荐
Random life-1
Pytorch learning notes 2 - about tensor
MFC 使用控制台打印程序信息
Bag of tricks training convolution network skills
CString to char[] function
Install visual studio 2019 steps and vs2019 offline installation package on win7
Paper artifact vs code + latex + latex workshop
Exploration of Clickhouse aggregation internal mechanism of aggregation
Perl introductory learning (VIII) subroutine
转义字符笔记
Word自动目录字体修改和行间距的问题
qt解析字符串转为json数据并解析
Hugging face 的问题记录 I
Graduation thesis | how to write literature review
Machine learning note 5 - logistic regression
论文神器 VS Code + LaTex + LaTex Workshop
Systemmediasize startup option added in esxi 7.0 update 1C
What happens when MySQL tables change from compressed tables to ordinary tables
Pytorch learning notes
Design and analysis of contactor coil control circuit