2009-09-21 05:28:27

by Mulyadi Santosa

[permalink] [raw]
Subject: Re: How can i see whether a process id is alive?

On Fri, Sep 18, 2009 at 5:17 PM, Driver-Seeker
<[email protected]> wrote:
> Hi
>
> ? I have a small question...
> I have the process id of an application.. I have to verify whether that
> process is alive or not from kernel space. How can i do that? do we have any
> such API's like isAlive(pid) ? [but googling didnt give me anything:(]

What do you mean by "alive"? Runnable state? All in all, I think you
can use find_task_by_vpid() function defined in linux/sched.h. It
needs one parameter: the pid of a task you're searching for and it
will return its task struct. There, you can check the state property.

Mind you that now PID are organized under namespace to accomodate
virtualization environment and I have no idea how to deal with this
new PID namespace schema. But looking at the find_task_by_vpid()
function implementation, it is a safe bet since it will use the same
namespace as the caller.

--
regards,

Mulyadi Santosa
Freelance Linux trainer
blog: the-hydra.blogspot.com