public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Petr Uzel <petr.uzel@centrum.cz>
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	[thread overview]
Message-ID: <200606281601.07029.petr.uzel@centrum.cz> (raw)
In-Reply-To: <200606281551.42342.petr.uzel@centrum.cz>

Dne středa 28 červen 2006 15:51 Petr Uzel napsal(a):
> Dne středa 28 červen 2006 15:04 Iain Buchanan napsal(a):
> > 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);
>
> 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 
directory /proc/pid_of_process. And by parsing status file in this directory 
you should get all the informations you want.

-- 
Petr Uzel
petr.uzel@centrum.cz
Jabber : knotor@njs.netlab.cz
ICQ : 101606095
Gentoo Linux

-- 
gentoo-user@gentoo.org mailing list



  reply	other threads:[~2006-06-28 14:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1151499883.17966.13.camel@orpheus>
2006-06-28 13:51 ` [gentoo-user] OT: get process name in c++ Petr Uzel
2006-06-28 14:01   ` Petr Uzel [this message]
2006-06-29  0:47     ` Iain Buchanan
2006-07-07  2:37       ` Iain Buchanan
2006-07-07  2:55         ` Richard Fish
2006-07-07  4:35           ` Iain Buchanan
2006-07-07  4:48             ` Richard Fish
2006-07-07  5:05               ` Iain Buchanan
2006-07-07 17:14                 ` Richard Fish
2006-07-07 20:53                   ` Uwe Thiem
2006-07-07 21:54                     ` Richard Fish
2006-07-10  0:00                       ` Iain Buchanan
2006-07-07 22:05         ` Richard Fish
2006-06-28 15:55 ` Richard Fish
2006-07-27  0:19 ` [gentoo-user] " Iain Buchanan
2006-07-27  4:35   ` Richard Fish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200606281601.07029.petr.uzel@centrum.cz \
    --to=petr.uzel@centrum.cz \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox