Why does getpid() return pid_t instead of int?

后端 未结 6 1088
太阳男子
太阳男子 2020-12-23 19:37

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

6条回答
  •  长情又很酷
    2020-12-23 19:54

    One thing to point out, in most answers I saw something along the lines of "using pid_t makes the code work on different systems", which is not necessarily true.

    I believe the precise wording should be: it makes the code 'compile' on different systems.

    As, for instance, compiling the code on a system that uses 32-bit pid_t will produce a binary that will probably break if run on another system that uses 64-bit pid_t.

提交回复
热议问题