What\'s the logic behind calls like getpid() returning a value of type pid_t instead of an unsigned int? Or int? How does
The reason is to allow nasty historical implementations to still be conformant. Suppose your historical implementation had (rather common):
short getpid(void);
Of course modern systems want pids to be at least 32-bit, but if the standard mandated:
int getpid(void);
then all historical implementations that had used short would become non-conformant. This was deemed unacceptable, so pid_t was created and the implementation was allowed to define pid_t whichever way it prefers.
Note that you are by no means obligated to use pid_t in your own code as long as you use a type that's large enough to store any pid (intmax_t for example would work just fine). The only reason pid_t needs to exist is for the standard to define getpid, waitpid, etc. in terms of it.