From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: fa528,d5363914c0117f3,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-04-24 09:05:03 PST Path: newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!oleane.net!oleane!nnrp.oleane.net!not-for-mail From: francois reygagne Newsgroups: comp.unix.tru64 Subject: a C fonction to check if a process is still there Date: Tue, 24 Apr 2001 18:03:27 +0200 Organization: opteway Message-ID: <3AE5A3CF.3D713992@opteway.com> NNTP-Posting-Host: sophia1.opteway.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: s1.read.news.oleane.net 988128207 15838 195.101.210.209 (24 Apr 2001 16:03:27 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Tue, 24 Apr 2001 16:03:27 +0000 (UTC) X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-12 i686) X-Accept-Language: en Xref: newsfeed.google.com comp.unix.tru64:2119 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//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