Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: francois reygagne <freygagne@opteway.com>
Subject: a C fonction to check if a process is still there
Date: Tue, 24 Apr 2001 18:03:27 +0200	[thread overview]
Message-ID: <3AE5A3CF.3D713992@opteway.com> (raw)

I'm looking for a C fonction to check if a process is still there
in memory and if exists get its pid In shell I could use the command ps
like
ps -e -o pid,user,args | grep myprocess | grep -v grep | awk '{print
$1}'

we could use instead
popen("ps -e -o pid,user,args | grep myprocess | grep -v grep | awk
'{print $1}'", "r");

but I dislike it.


Is there an elegant solution dedicated to Tru64 to get the list of
processes in memory
and then able to get the right one ?

On linux it's easy, I scan the files /proc/<pid>/cmdline and where
cmdline contains the
absolute path of the process i'm looking for, i got the pid ans that's
it !

so my function signature is
pid_t get_pid(char* absolute_pathname);
the returned pid_t is -1 on error otherwise the pid of the matched
process.


Fran�ois REYGAGNE. Software Architect.
opt[e]way S.A., 2881 route des Cr�tes, BP308
06906 Sophia Antipolis Cedex, FRANCE
t�l: +33 (0)4 92 95 27 01    http://www.opteway.com





                 reply	other threads:[~2001-04-24 16:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox