Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
573 views
in Technique[技术] by (71.8m points)

c - Size of pid_t, uid_t, gid_t on Linux

On Linux systems (either 32- or 64-bit), what is the size of pid_t, uid_t, and gid_t?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
#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));
}

EDIT: Per popular request (and because, realistically, 99% of the people coming to this question are going to be running x86 or x86_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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...