difference of pid_t and int in C

Viewed 13810

what's the difference between pid_t datatype and int when getting process id? I saw something like:

pid_t getpid(void);

but whats the difference between it and

int getpid(void);
2 Answers

Quoting from the libc manual:

The pid_t data type is a signed integer type which is capable of representing a process ID. In the GNU C Library, this is an int.

data types that ends with "_t", are usually a defined type variable in C and C++ as an unwritten law. according to that law, "pid_t" is a data type which is defined somewhere else but "int" a standard type; so to know the differences you need to know how "pid_t" is defined.

Related