Hi,

I posted this email a short while ago, and got some great tips for
accessing /proc/self/status to read the process name.  However, guess
what I just found (after I've finished and tested my /proc/
implementation?)

man 3 program_invocation_short_name:

NAME
       program_invocation_name,  program_invocation_short_name  -  obtain name
       used to invoke calling program
...

DESCRIPTION
       program_invocation_name contains the name that was used to  invoke  the
       calling  program.   This is the same as the value of argv[0] in main(),
       with the  difference  that  the  scope  of  program_invocation_name  is
       global.

cool!  Oh well, reading /proc/ was an experience :)

On Wed, 2006-06-28 at 22:34 +0930, Iain Buchanan wrote:
> Hi again :)
> 
> I have been googling for this one for a little while, and trying various
> 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 within
> 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 = getpsname (pid);
> 
> But does that exist?  Maybe there's an interface to /proc that I'm
> unaware of?
> 
> I'd appreciate any tips!
> 
> thanks,

cya,
-- 
Iain Buchanan <iaindb at netspace dot net dot au>

If you are shooting under 80 you are neglecting your business;
over 80 you are neglecting your golf.
                -- Walter Hagen

-- 
gentoo-user@gentoo.org mailing list

Reply via email to