Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 784
Joe Shaw Avatar asked Dec 17 '09 16:12

Joe Shaw


People also ask

Where is pid_t defined Linux?

The time_t datatype is a data type in the ISO C library defined for storing system time values. Such values are returned from the standard time() library function. This type is a typedef defined in the standard <time. h> header.

What is the type of pid_ t?

The pid_t data type is a signed integer type which is capable of representing a process ID. In the GNU library, this is an int . The getpid function returns the process ID of the current process. The getppid function returns the process ID of the parent of the current process.

What is Uid_t?

Data Type: uid_t. This is an integer data type used to represent user IDs. In the GNU C Library, this is an alias for unsigned int .


1 Answers

#include <stdio.h> #include <sys/types.h>  int main() {     printf("pid_t: %zu\n", sizeof(pid_t));     printf("uid_t: %zu\n", sizeof(uid_t));     printf("gid_t: %zu\n", 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 
like image 76
Dave Avatar answered Sep 21 '22 08:09

Dave