获取进程 pid ppid getpid

创建日期: 2024-07-04 16:07 | 作者: 风波 | 浏览次数: 15 | 分类: C++

来源:https://cplusplus.com/forum/general/85017/

#include<sys/types.h>
#include<iostream>

using namespace std;

int main()
{
    int pid,ppid,cpid;
    cout<<"Main Process with pid : "<<getpid();
    cout<<"\nSplit starts : ";
    pid=fork();
    if(pid==0)
    {
        cout<<"\nChild Process with pid :"<<getpid();
    }
    else
    {
        cout<<"\nParent Process with pid :"<<getpid();
    }
}
15 浏览
12 爬虫
0 评论