当前位置:网站首页>[learning notes] process creation
[learning notes] process creation
2022-07-28 06:56:00 【Step on a meteor】
#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;
}
// Subprocesses
if(pid == 0) {
printf("child process!\n");
printf("child PPID:%d,PID:%d\n", getppid(), getpid());
pipeline_child();
} else {
// The parent process
sleep(1);
printf("father process!\n");
printf("father PPID:%d,PID:%d\n", getppid(), getpid());
pipeline_father();
}
return 0;
}
边栏推荐
- Question brushing record ---- reverse the linked list (reverse the whole linked list)
- Hdu-5806-nanoapelovesequence Ⅱ (ruler method)
- 浅谈Cookie和Session
- 链表中结点的插入和删除
- Scratch command
- Question brushing record -- binary tree
- DNS forward resolution experiment
- Question skimming record - hash table
- What is a linear table?
- Repair the faulty sector
猜你喜欢

What's a good gift for Tanabata? Niche and advanced product gift recommendation

2022 Tanabata gift recommendation! Nice, cheap and practical gift recommendation

NAT和PAT的原理及配置

VMware Workstation 配置net模式

思寒漫谈测试人职业发展

Skimming records -- sequence traversal of binary tree

Network - transport layer (detailed version)

搭建PHP7私有仓库

网络——传输层(详细版)

What is the good brand of air conduction Bluetooth headset and the best brand recommendation of air conduction headset
随机推荐
Shell script - regular expression
如何描述一个BUG以及BUG级别的定义、生命周期
搭建PHP7私有仓库
What kind of air conduction Bluetooth headset with good configuration is recommended
Ubuntu18.04+Centos7配置redis主从【学习笔记】
[explain in detail how to realize Sanzi chess step by step]
网络——传输层(详细版)
Iptables firewall
DNS forward resolution experiment
Prometheus monitoring Nacos
一、PXE概述和安装
Compilation and preprocessing of C language
测试面试题集锦(二)| 测试工具篇(附答案)
shell脚本——“三剑客”之awk命令
MySQL主从
NFS 共享存储服务
NFS shared storage service
技术分享 | 接口自动化测试中,如何做断言验证?
技术分享 | 服务端接口自动化测试, Requests 库的这些功能你了解吗?
What is the most practical gift for Tanabata? A gift that will never go wrong is worth buying