id.cpp
上传用户:cqgdffbw
上传日期:2021-04-27
资源大小:17k
文件大小:1k
- #include <unistd.h>
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "The pid is " << getpid() << endl;
- cout << "the session id is " << getsid(getpid()) << endl;
- cout << "the uid is " << getuid() << endl;
- cout << "get euid is " << geteuid() << endl;
- cout << "the gid is " << getgid() << endl;
- cout << "get egid is " << getegid() << endl;
- cout << "get process's group id " << getpgid(getpid()) << endl;
- int pid = fork();
- if (pid == 0) {
- cout << "child process's gid is " << getpid() << endl;
- cout << "child process's group id is "<< getpgid(getpid()) << endl;
- }
- }