Today, what are the bests ways to know if a deamon is running without
knowing its PID ?
My old technique (used until now), is based on recovering the PID saved by
the own process in a special and known location (like a file), almost all
times persisted (PERSISTENCE IS A PROBLEM).
Luciano
On Tue, 1 Mar 2005, Hareesh Nagarajan wrote:
> Hi,
>
> Can a process check if a given PID exists or not? In other words can a
> process check if an unrelated process is alive? Is there any system
> call that does this?
>
Use kill() with a second argument being zero.
if (kill(pid, 0) == -1)
{
/* Process is not there. */
}
else
{
/* Process is alive. */
}
Holger