Re: How can i see whether a process id is alive?

From: Mulyadi Santosa
Date: Mon Sep 21 2009 - 01:28:41 EST


On Fri, Sep 18, 2009 at 5:17 PM, Driver-Seeker
<linuxdriverforme@xxxxxxxxx> 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
--
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/