Skip to contentSkip to conversation

How can i see whether a process id is alive?

DISCUSSION Mulyadi Santosa 1 participant 1 message Sep 21, 2009 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 6 lines · Driver-Seeker

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.

Signature · 5 lines
regards,

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