Why does getpid() return pid_t instead of int?

ntl0ve picture ntl0ve · Sep 11, 2011 · Viewed 57.1k times · Source

What's the logic behind calls like getpid() returning a value of type pid_t instead of an unsigned int? Or int? How does this help?

I'm guessing this has to do with portability? Guaranteeing that pid_t is the same size across different platforms that may have different sizes of ints etc.?

Answer

zvrba picture zvrba · Sep 11, 2011

I think it's the opposite: making the program portable across platforms, regardless of whether, e.g., a PID is 16 or 32 bits (or even longer).