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
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" 
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to