[PATCH 5/7] pid: Implement pid_nr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jan Engelhardt <jengelh at linux01.gwdg.de> writes:

>>> +static inline pid_t pid_nr(struct pid *pid)
>>> +{
>>> +       pid_t nr = 0;
>>> +       if (pid)
>>> +               nr = pid->nr;
>>> +       return nr;
>>> +} 
>>
>>When is it valid to be passing around a NULL 'struct pid *'?
>
> Is 0 even the right thing to return in the rare case that pid == NULL?
> -1 maybe?

I believe 0 is what we have used elsewhere.

A negative value for a pid is likely to be taken as the group of all
processes, or -EPERM, and it does really confusing things when fed through
the current f_getown implementation, with PIDTYPE_PGRP.

The only other possible interpretations of 0 are the idle process and
yourself.  There is still some potential there, but largely 0 is much
less likely to be confused than -1.  Especially as it doesn't change
when you negate it.

Eric


[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux