linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Check if a process exists? (EXTENDING THE QUESTION)
@ 2005-04-09  1:50 lucianolnx
  2005-04-09  7:24 ` M.Baris Demiray
  2005-04-11  1:59 ` Ron Michael Khu
  0 siblings, 2 replies; 3+ messages in thread
From: lucianolnx @ 2005-04-09  1:50 UTC (permalink / raw)
  To: linux-c-programming

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 721 bytes --]

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 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-04-11  1:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-09  1:50 Check if a process exists? (EXTENDING THE QUESTION) lucianolnx
2005-04-09  7:24 ` M.Baris Demiray
2005-04-11  1:59 ` Ron Michael Khu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).