pid: process id,进程ID
ppid: parent process id,父进程ID
uid: real user id, 用户ID
euid: effective user id,有效用户ID
gid: real group id,组ID
egid: effictive group id,有效组ID
下面来看一下简单程序的输出:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
printf(
"getpid: %d\ngetppid: %d\ngetuid: %d\ngeteuid: %d\ngetgid: %d\ngetegid: %d\n",
getpid(), getppid(), getuid(), geteuid(), getgid(),
getegid());
return 0;
}
执行结果为:
[chinsung@thinkpad apue]$ ./a.out
getpid: 9102
getppid: 3705
getuid: 1000
geteuid: 1000
getgid: 1000
getegid: 1000
[chinsung@thinkpad apue]$ ps aux | grep '3705'
chinsung 3705 0.0 0.0 20044 2224 pts/1 Ss 10:23 0:00 /bin/bash
chinsung 9105 0.0 0.0 12260 996 pts/1 S+ 15:17 0:00 grep 3705
在我的系统中,当前用户名为chinsung,其用户ID为1000,所属组为chinsung,其组ID也为1000,可以从上面的结果中看出,在本程序中uid和euid是等价的,gid和egid是等价的。当前进程的父进程为shell。