linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "M.Baris Demiray" <baris@labristeknoloji.com>
To: lucianolnx <lucianolnx@ig.com.br>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Check if a process exists? (EXTENDING THE QUESTION)
Date: Sat, 09 Apr 2005 10:24:55 +0300	[thread overview]
Message-ID: <42578347.5040605@labristeknoloji.com> (raw)
In-Reply-To: <20050409_015010_024210.lucianolnx@ig.com.br>

[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]


lucianolnx wrote:
> Today, what are the bests ways to know if a deamon is running without 
> knowing its PID ? 

I'm not sure whether this is `the best way' but you can parse some proc
file system entry. Especially /proc/$pid/cmdline and /proc/$pid/status
will be useful. And you will have to search all the /proc/$pid entries
since you don't know the pid..

For example, they provide following information for clamd.

[baris@rhinox]$ ps aux|grep clamd
clamav     424  0.0  3.1  11520  7856 ?        Ss   01:35   0:03 
/usr/sbin/clamd
clamav    1184  0.0  3.1  11520  7856 ?        S    09:38   0:00 
/usr/sbin/clamd
baris     1238  0.0  0.2   1688   712 pts/2    S+   09:58   0:00 grep clamd
[baris@rhinox]$ cat /proc/1184/cmdline
/usr/sbin/clamd
[baris@rhinox]$ cat /proc/1184/status
Name:   clamd
State:  S (sleeping)
Tgid:   1184
Pid:    1184
PPid:   424
....
....

I also should add that /proc filesystem is _optional_ in configuration.
Highly likely it will exist on a target system but a little possibility
of being it unselected still there.

> 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 

-- 
"You have to understand, most of these people are not ready to be
unplugged. And many of them are no inert, so hopelessly dependent
on the system, that they will fight to protect it."
                                                         Morpheus

[-- Attachment #2: baris.vcf --]
[-- Type: text/x-vcard, Size: 342 bytes --]

begin:vcard
fn:M.Baris Demiray
n:Demiray;M.Baris
org:Labris Teknoloji
adr:ODTU;;Teknokent Silikon Blok No:24;Ankara;;06531;Turkiye
email;internet:baris@labristeknoloji.com
title:Yazilim Gelistirme Uzmani
tel;work:+903122101490
tel;fax:+903122101492
x-mozilla-html:FALSE
url:http://www.labristeknoloji.com
version:2.1
end:vcard


  reply	other threads:[~2005-04-09  7:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-09  1:50 Check if a process exists? (EXTENDING THE QUESTION) lucianolnx
2005-04-09  7:24 ` M.Baris Demiray [this message]
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=42578347.5040605@labristeknoloji.com \
    --to=baris@labristeknoloji.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=lucianolnx@ig.com.br \
    /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).