Re: vsize from within C++ (UNCLASSIFIED)



You could always use "popen(3)" to run the command from a C program, then read the output of the command.

Tim

m.roth@xxxxxxxxx wrote:
Steve wrote:
[mailto:redhat-list-bounces@xxxxxxxxxx] On Behalf Of m.roth@xxxxxxxxx
Sent: Wednesday, April 14, 2010 8:17 AM
Steve wrote:

Is it possible for a process to obtain information about itself (such
as that provided by "top"), specifically vsize?
Sure. I never needed it, but a brief google for vsize linux c
programming gets
<http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c>

Thanks Mark! I was working with /proc/self/stat and getting to the
vSize value using system() and an awk command, but was having trouble
getting the value back into a variable in my program...always getting 0
which was the value passed back from system() ... 0 = success.

Right - system, either in awk or perl, only returns the status of the
command, and I'm not aware of any way to actually get info from it, other
than the *really* ugly way of <awkcmd> > /tmp/awkcmd.output; open/read
/tmp/awkcmd.output.
I'll give this a try. My Google searches didn't come up with anything
this good.

You're welcome, Searches are their own art form - that's why I gave the
terms I used for the search, so as to give you *how* I found this. I
usually work my way down the tree: linux (top) vmsize (what I want to
find) c programming (what form I need the answer in).

mark

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list



Relevant Pages

  • Re: Wordsearch:AI Insanity
    ... bios, what with being hard-coded and all. ... Stop with an error message. ... an undefined command or something, so what happens depends entirely on ... So it's programmed to alter its own programming depending on input? ...
    (rec.arts.sf.composition)
  • Re: Great SWT Program
    ... And, of course, none of the nasty things that you have said or implied ... such rot and squeezing out Java programming related traffic with emacs ... I didn't claim that they could not learn a load of programming skills ... bit is the entire command but is only part of the full command line, ...
    (comp.lang.java.programmer)
  • Re: Great SWT Program
    ... such rot and squeezing out Java programming related traffic with emacs ... I didn't claim that they could not learn a load of programming skills ... CLI skills are hardly "much of the skillset of programming" - but I ... bit is the entire command but is only part of the full command line, ...
    (comp.lang.java.programmer)
  • [RFC/PATCH 2/4] uasp: COMMAND IU handling infrastructure
    ... This patch defines APIs for different COMMAND IUs implementation ... * @udev: Programming view of UASP device. ... * @cmdiu: ...
    (Linux-Kernel)
  • Re: Overflowing a Long
    ... Maybe you had to "grow up" on a command line to appreciate the clarity ... strictly in terms of 3GLs or even machine language. ... I would guess that you probably started programming even earlier ... and thus you're more deeply entrenched in the programming style ...
    (microsoft.public.vb.general.discussion)