Re: [PATCH] use pid_alive in proc_pid_status

From: Manfred Spraul
Date: Mon Nov 29 2004 - 13:00:19 EST


Ingo Molnar wrote:

* Andrew Morton <akpm@xxxxxxxx> wrote:



+int pid_alive(struct task_struct *p)
+{
+ return p->pids[PIDTYPE_PID].nr != 0;
+}


Can we not simply test p->exit_state? That's already done in quite a
few places and making things consistent would be nice.



as long as it's accessed from under the tasklist_lock, it ought to be
fine to check for p->exit_state != EXIT_DEAD and dereference
p->group_leader afterwards.



The tricky part is proc_pid_unhash()/proc_pid_flush(): Right now removing a pid from the pid bitmap and disabling /proc/<pid>/* is atomic: Both operations are done under tasklist_lock.
I think it would be better to modify pid_alive to p->exit_state and disable /proc/<pid>/* access when the exit state is set to DEAD, but that that would be a larger change. Probably unhash and flush could be merged into one function.
But I don't understand the lines in wait_task_zombie that reset exit_state from DEAD to ZOMBIE, so perhaps I overlook something.

--
Manfred
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/