From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1FvaoF-0003dh-2o for garchives@archives.gentoo.org; Wed, 28 Jun 2006 14:14:27 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.7/8.13.6) with SMTP id k5SECfZv024599; Wed, 28 Jun 2006 14:12:41 GMT Received: from slimak.dkm.cz (slimak.dkm.cz [62.24.64.34]) by robin.gentoo.org (8.13.7/8.13.6) with SMTP id k5SE17Yl012086 for ; Wed, 28 Jun 2006 14:01:07 GMT Received: (qmail 31244 invoked by uid 0); 28 Jun 2006 14:01:07 -0000 Received: from r5cu43.chello.upc.cz (HELO knot) (86.49.110.43) by slimak.dkm.cz with SMTP; 28 Jun 2006 14:01:07 -0000 From: Petr Uzel To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] OT: get process name in c++ Date: Wed, 28 Jun 2006 16:01:06 +0200 User-Agent: KMail/1.9.1 References: <1151499883.17966.13.camel@orpheus> <200606281551.42342.petr.uzel@centrum.cz> In-Reply-To: <200606281551.42342.petr.uzel@centrum.cz> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1250" Content-Disposition: inline Message-Id: <200606281601.07029.petr.uzel@centrum.cz> X-MIME-Autoconverted: from quoted-printable to 8bit by robin.gentoo.org id k5SE17Yl012086 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by robin.gentoo.org id k5SECfaD024599 X-Archives-Salt: bb456d64-f964-4087-a766-3d1442c32297 X-Archives-Hash: a83835179ea043d6c83abbf6a114302b Dne st=F8eda 28 =E8erven 2006 15:51 Petr Uzel napsal(a): > Dne st=F8eda 28 =E8erven 2006 15:04 Iain Buchanan napsal(a): > > Hi again :) > > > > I have been googling for this one for a little while, and trying vari= ous > > options, but I can't seem to find it: How do I get the process from > > within a process in c or c++? > > > > I don't want to use argv[0], because the particular place is deep wit= hin > > classes, and there are too many (I'm doing some porting) to edit all = of > > their constructors, for example, to pass argv[0]. > > > > something like > > > > char *name =3D getpsname (pid); > > Hi, > what about directly reading /proc/pid_of_the_process/stat (may be some > other file in this directory). Now I found better solution : file /proc/self/status is a link pointing to the=20 directory /proc/pid_of_process. And by parsing status file in this direct= ory=20 you should get all the informations you want. --=20 Petr Uzel petr.uzel@centrum.cz Jabber : knotor@njs.netlab.cz ICQ : 101606095 Gentoo Linux --=20 gentoo-user@gentoo.org mailing list