Re: pid_t data type



And I think my question is misunderstood. I just want you to tell me
if there are cases where long will fail to take place of pid_t. I dont
care if pid_t is an int or short or long!

Yes, there are.

1. On a system where sizeof(int) != sizeof(long), and pid_t is
long, and you don't have a proper prototype in scope for the function
you are calling that takes a pid_t as an argument, you'll be passing
an argument of the wrong size and it is likely to be interpreted
incorrectly. This is preventable with good programming style (use
prototypes).

2. If you pass a pid_t to printf() without casting it, you'll have
to use the correct format or it will likely screw up. This is
preventable with good programming styple, and you probably want to
cast it to a intmax_t.

3. On a system where sizeof(pid_t) > sizeof(long), a long won't
hold a whole pid_t, and putting it in a long will likely mangle it.
It is possible that a pid_t might in the future contain an IPv8
address, a digital signature, and certificates for the signature
along with a number that's very difficult to guess (perhaps 8Kbytes
total). This is preventable by using pid_t rather than long.

4. If you ever use a pointer-to-pid_t anywhere, it has to point
to something of the correct size. I don't know of any existing
system functions that do that. This might change.

.