linux获取当前进程pid 如何通过父进程pid获取子进程pid?

如何通过父进程pid获取子进程pid?Getppid()获取父进程的ID,getpid()获取当前进程的ID。例如,int main(){int PID=fork()if(PID==0){//chil

如何通过父进程pid获取子进程pid?

Getppid()获取父进程的ID,

getpid()获取当前进程的ID。

例如,

int main()

{

int PID=fork()

if(PID==0)

{

//child

printf(“parentid is%dn”,Getppid())]}

]esle

{

]printf(“I”m parent,ID%dn”,getpid())

wait(null)

}

!return 0

}

!]然后程序编译是正确的,但是运行时出现的“实时信号”没有源代码谁也帮不了你。您可以使用GDB进行调试。