且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Linux 上 pid_t、uid_t、gid_t 的大小

更新时间:2022-06-19 01:39:32

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

int main()
{
    printf("pid_t: %zu
", sizeof(pid_t));
    printf("uid_t: %zu
", sizeof(uid_t));
    printf("gid_t: %zu
", sizeof(gid_t));
}

每个受欢迎的请求(并且因为,实际上,99% 的人会使用 x86 或 x86_64)...

Per popular request (and because, realistically, 99% of the people coming to this question are going to be running x86 or x86_64)...

在运行 Linux >= 3.0.0 的 i686 和 x86_64(因此,32 位和 64 位)处理器上,答案是:

On an i686 and x86_64 (so, 32-bit and 64-bit) processor running Linux >= 3.0.0, the answer is:

pid_t: 4
uid_t: 4
gid_t: 4