PID: possible values?

Hello,

Can a process ever get a PID of 0?
What is the range of valid PIDs?

Thanks,
-david

“David Alessio” <david.alessio@hsa.hitachi.com> wrote in message
news:3CB76665.861DB2BD@hsa.hitachi.com

Hello,

Can a process ever get a PID of 0?
What is the range of valid PIDs?

I think it would be a mistake to rely on PID having a range.
If there is one, it’s undefined, which means it can change
in futur releases.

I don’t think pid of 0 or -1 are valid but they may represent
something else, like invalid for -1 or self for 0.

Thanks,
-david

Mario Charest <goto@nothingness.com> wrote:
: I don’t think pid of 0 or -1 are valid but they may represent
: something else, like invalid for -1 or self for 0.

Many of the functions that take a pid as an argument interpret 0 as meaning
the current process. I haven’t seen any that interpret 0 as anything else,
but I agree with Mario: don’t count on it.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

%% Steve Reid <stever@qnx.com> writes:

sr> Mario Charest <goto@nothingness.com> wrote:
: I don’t think pid of 0 or -1 are valid but they may represent
: something else, like invalid for -1 or self for 0.

sr> Many of the functions that take a pid as an argument interpret 0
sr> as meaning the current process. I haven’t seen any that interpret
sr> 0 as anything else, but I agree with Mario: don’t count on it.

Not clear whether you’re responding to the OP’s question on whether PID
0 is ever valid, or Mario’s suggestion that PID 0 means “self”.

PID 0 is never a valid PID, you can always count on that. (Why can
you count on that? Remember all processes are created with fork(), and
what does fork() return? :slight_smile:)

As for what the invalid PID value of 0 means in different contexts,
that’s context-specific; you definitely shouldn’t count on it always
meaning the same thing.

Paul D. Smith <pausmith@nortelnetworks.com> HASMAT–HA Software Mthds & Tools
“Please remain calm…I may be mad, but I am a professional.” --Mad Scientist

These are my opinions—Nortel Networks takes no responsibility for them.