Gentoo Archives: gentoo-user

From: Petr Uzel <petr.uzel@×××××××.cz>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] OT: get process name in c++
Date: Wed, 28 Jun 2006 14:14:27
Message-Id: 200606281601.07029.petr.uzel@centrum.cz
In Reply to: Re: [gentoo-user] OT: get process name in c++ by Petr Uzel
1 Dne støeda 28 èerven 2006 15:51 Petr Uzel napsal(a):
2 > Dne støeda 28 èerven 2006 15:04 Iain Buchanan napsal(a):
3 > > Hi again :)
4 > >
5 > > I have been googling for this one for a little while, and trying various
6 > > options, but I can't seem to find it: How do I get the process from
7 > > within a process in c or c++?
8 > >
9 > > I don't want to use argv[0], because the particular place is deep within
10 > > classes, and there are too many (I'm doing some porting) to edit all of
11 > > their constructors, for example, to pass argv[0].
12 > >
13 > > something like
14 > >
15 > > char *name = getpsname (pid);
16 >
17 > Hi,
18 > what about directly reading /proc/pid_of_the_process/stat (may be some
19 > other file in this directory).
20
21 Now I found better solution :
22 file /proc/self/status is a link pointing to the
23 directory /proc/pid_of_process. And by parsing status file in this directory
24 you should get all the informations you want.
25
26 --
27 Petr Uzel
28 petr.uzel@×××××××.cz
29 Jabber : knotor@××××××××××.cz
30 ICQ : 101606095
31 Gentoo Linux
32
33 --
34 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] OT: get process name in c++ Iain Buchanan <iaindb@××××××××××××.au>