linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: lucianolnx <lucianolnx@ig.com.br>
To: linux-c-programming@vger.kernel.org
Subject: Re: Check if a process exists? (EXTENDING THE QUESTION)
Date: Fri, 8 Apr 2005 22:50:10 -0300	[thread overview]
Message-ID: <20050409_015010_024210.lucianolnx@ig.com.br> (raw)

[-- 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 

             reply	other threads:[~2005-04-09  1:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-09  1:50 lucianolnx [this message]
2005-04-09  7:24 ` Check if a process exists? (EXTENDING THE QUESTION) M.Baris Demiray
2005-04-11  1:59 ` Ron Michael Khu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050409_015010_024210.lucianolnx@ig.com.br \
    --to=lucianolnx@ig.com.br \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).