1 |
Hi, |
2 |
|
3 |
I posted this email a short while ago, and got some great tips for |
4 |
accessing /proc/self/status to read the process name. However, guess |
5 |
what I just found (after I've finished and tested my /proc/ |
6 |
implementation?) |
7 |
|
8 |
man 3 program_invocation_short_name: |
9 |
|
10 |
NAME |
11 |
program_invocation_name, program_invocation_short_name - obtain name |
12 |
used to invoke calling program |
13 |
... |
14 |
|
15 |
DESCRIPTION |
16 |
program_invocation_name contains the name that was used to invoke the |
17 |
calling program. This is the same as the value of argv[0] in main(), |
18 |
with the difference that the scope of program_invocation_name is |
19 |
global. |
20 |
|
21 |
cool! Oh well, reading /proc/ was an experience :) |
22 |
|
23 |
On Wed, 2006-06-28 at 22:34 +0930, Iain Buchanan wrote: |
24 |
> Hi again :) |
25 |
> |
26 |
> I have been googling for this one for a little while, and trying various |
27 |
> options, but I can't seem to find it: How do I get the process from |
28 |
> within a process in c or c++? |
29 |
> |
30 |
> I don't want to use argv[0], because the particular place is deep within |
31 |
> classes, and there are too many (I'm doing some porting) to edit all of |
32 |
> their constructors, for example, to pass argv[0]. |
33 |
> |
34 |
> something like |
35 |
> |
36 |
> char *name = getpsname (pid); |
37 |
> |
38 |
> But does that exist? Maybe there's an interface to /proc that I'm |
39 |
> unaware of? |
40 |
> |
41 |
> I'd appreciate any tips! |
42 |
> |
43 |
> thanks, |
44 |
|
45 |
cya, |
46 |
-- |
47 |
Iain Buchanan <iaindb at netspace dot net dot au> |
48 |
|
49 |
If you are shooting under 80 you are neglecting your business; |
50 |
over 80 you are neglecting your golf. |
51 |
-- Walter Hagen |
52 |
|
53 |
-- |
54 |
gentoo-user@g.o mailing list |