Sorry, originally sent a reply to loody instead of Shyam. On Sat, 2010-05-22 at 21:29 +1200, Simon Kitching wrote: > On Sat, 2010-05-22 at 11:30 +0700, Mulyadi Santosa wrote: > > On Fri, May 21, 2010 at 19:33, Shyam Burkule <shyam.burkule@xxxxxxxxx> wrote: > > > Hi All, > > > I am using Linux kernel 2.6.27(SLES11). I am getting one strange problem. > > > I am using task_pid function followed by get_pid function to get pid > > > structure. > > > Here is code snippet, > > > struct *pid = get_pid(task_pid(current)); > > > > > > I am saving this pid structure in a variable which is used later to kill the > > > same process using kill_pid providing the same "pid *" which we saved > > > earlier. Since kill_pid() requires "pid *", we have save this somewhere > > > during process creation. Whenever we use get(task_pid(current)) in the code, > > > I observed that the process is not visible in "ps -ef" as well as "/proc" > > > filesystem. > > > > The codes say that get_pid increments the "count" field of the pid > > struct. I failed to find the related code in fs/proc that says > > anything about "don't show a task with count higher than 0". > > > > Thus, I could offer two hypotheses: > > a. The code that "hides" the pid in /proc is something else, probably > > additional code not included in mainline (since you're saying it's > > SLES kernel, right?) > > > > b. it's just coincidence, that when you do something on this pid, you > > accidentally remove the task structure, or at least the pid struct. > > Shyam, did you mean that > > (a) as soon as you call get_pid(task_pid(current)) the pid disappears > from ps and proc, or > > (b) that you expect the pid to remain listed in ps and proc after the > task exits, because you earlier called get_pid()? > > If (a) then I'm puzzled. Like Mulyadi, I also can't see anything that > might explain why ps would be affected by get_pid. > > The only effect of get_pid is to increment the "count" member; I changed > the name of this field and recompiled the kernel and this verified that > the only places using count are: > * kernel/pid.c > * include/linux/pid.h > * include/linux/init_task.h > > pid.c only uses it in get_pid and put_pid to reference-count the pid > struct and free it when count=0. > > So there is clearly nothing in the proc filesystem or elsewhere that is > looking at the count. And get_pid isn't moving structures from one list > to another or anything like that. > > If (b), then that's not what get_pid is for. It ensures that the struct > pid continues to exist, but the pid# itself becomes "unused", and is > free for the OS to reuse. > > NB: I'm looking at 2.6.34... > > Cheers, > Simon > > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx > Please read the FAQ at http://kernelnewbies.org/FAQ > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ