#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
int main(int argc,char *argv[])
{
pid_t pid,ppid,pgid;
pid = getpid();
printf("pid = %d\n",pid);
ppid = getppid();
printf("father pid = %d\n",ppid);
pgid = getpgid(pid);
printf("group pid = %d\n",pgid);
return 0;
}
Linux C 查询当前进程号、父进程号、进程组号
![](https://img-home.csdnimg.cn/images/20240711042549.png)