[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4AE165A4.70706@ladisch.de>
Date: Fri, 23 Oct 2009 10:13:24 +0200
From: Clemens Ladisch <clemens@...isch.de>
To: "Leonidas ." <leonidas137@...il.com>
CC: linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: Process id recycling and status of tasks
Leonidas . wrote:
> 1. What would be an ideal way to check if a task is alive or dead from
> kernel space?
Get a reference to the task's pid (call get_task_pid(), or get_pid() on
the return value of task_pid()), then later check whether pid_task()
works.
(pid_alive() is not what you want because this would require that you
hold a reference to the task_struct.)
> even though a certain pid might exist, it might have got recycled by
> the time I check again, right?
The functions above do not work with PID numbers but with struct pid
which is a reference-counted object. (The functions with "get" in their
name increase the reference count, so don't forget to put_pid() when you
no longer need it.) See also the big comment in include/linux/pid.h.
HTH
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists