Re: [2.4] proc_self_readlink()/proc_self_follow_link()

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

 



Hi Tetsuo ...

> Hello.
>
> sys_getpid() returns current->tgid for both 2.4 and 2.6 kernels.
>   http://lxr.linux.no/source/kernel/timer.c?v=2.4.28#L753
>   http://lxr.linux.no/source/kernel/timer.c?v=2.6.11#L967
>
> Then, why not use current->tgid instead of current->pid
> in proc_self_readlink()/proc_self_follow_link() for 2.4 kernels?
>   http://lxr.linux.no/source/fs/proc/base.c?v=2.4.28#L1017
>   http://lxr.linux.no/source/fs/proc/base.c?v=2.6.11#L1589

Interesting analysis! Allow me to share my opinion.

We know that tgid is equal to pid, but whenever new process is created 
using CLONE_THREAD, they are no longer equal. tgid is same for all 
process under same process/thread group while pid is still unique. This 
way, we satisfy POSIX rule that getpid returns same pid for all thread 
under same group.

But, in case of /proc/self, we must point to distinct ID, no matter it 
is created using CLONE_THREAD or not. So, task_struct->pid is the 
answer IMHO.

I haven't checked this on 2.6.x though...

Comments?

regards

Mulyadi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux