Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* a C fonction to check if a process is still there
@ 2001-04-24 16:03 francois reygagne
  0 siblings, 0 replies; only message in thread
From: francois reygagne @ 2001-04-24 16:03 UTC (permalink / 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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-24 16:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-24 16:03 a C fonction to check if a process is still there francois reygagne

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