Is it possible for a process to obtain information about itself (such as
that provided by "top"), specifically vsize?
Thank you in advance,
Steve
Classification: UNCLASSIFIED
Caveats: NONE
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
04-14-2010, 01:17 PM
vsize from within C++ (UNCLASSIFIED)
> Classification: UNCLASSIFIED
> Caveats: NONE
>
> 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
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
04-14-2010, 02:06 PM
"Glasgow, Steven Mr CIV USA TRADOC"
vsize from within C++ (UNCLASSIFIED)
Classification: UNCLASSIFIED
Caveats: NONE
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.
I'll give this a try. My Google searches didn't come up with anything
this good.
Steve
-----Original Message-----
From: redhat-list-bounces@redhat.com
[mailto:redhat-list-bounces@redhat.com] On Behalf Of m.roth@5-cent.us
Sent: Wednesday, April 14, 2010 8:17 AM
To: General Red Hat Linux discussion list
Subject: Re: vsize from within C++ (UNCLASSIFIED)
> Classification: UNCLASSIFIED
> Caveats: NONE
>
> 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
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
04-14-2010, 03:31 PM
vsize from within C++ (UNCLASSIFIED)
Steve wrote:
> [mailto:redhat-list-bounces@redhat.com] On Behalf Of m.roth@5-cent.us
> 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@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
04-14-2010, 04:08 PM
"Glasgow, Steven Mr CIV USA TRADOC"
vsize from within C++ (UNCLASSIFIED)
Classification: UNCLASSIFIED
Caveats: NONE
BTW, it worked and had the added feature of being EXTREMELY simple.
Thanks again,
Steve
-----Original Message-----
From: redhat-list-bounces@redhat.com
[mailto:redhat-list-bounces@redhat.com] On Behalf Of m.roth@5-cent.us
Sent: Wednesday, April 14, 2010 10:32 AM
To: General Red Hat Linux discussion list
Subject: RE: vsize from within C++ (UNCLASSIFIED)
Steve wrote:
> [mailto:redhat-list-bounces@redhat.com] On Behalf Of m.roth@5-cent.us
> 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).
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@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
04-14-2010, 04:53 PM
"Burke, Thomas G."
vsize from within C++ (UNCLASSIFIED)
Sounds "awk"ward...
Sorry, just couldn't resist.
'
-----Original Message-----
From: redhat-list-bounces@redhat.com
[mailto:redhat-list-bounces@redhat.com] On Behalf Of Tim P. Starrin
Sent: Wednesday, April 14, 2010 12:29 PM
To: General Red Hat Linux discussion list
Subject: 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@5-cent.us wrote:
> Steve wrote:
>
>> [mailto:redhat-list-bounces@redhat.com] On Behalf Of m.roth@5-cent.us
>> 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-ru
n-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@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
04-14-2010, 05:05 PM
"Glasgow, Steven Mr CIV USA TRADOC"
vsize from within C++ (UNCLASSIFIED)
Classification: UNCLASSIFIED
Caveats: NONE
Thank Tim,
I'll remember this should I need to access other commands from
c++. I can definitely see where this would come in useful. For now,
simply reading the stat file does what I need.
Steve
-----Original Message-----
From: redhat-list-bounces@redhat.com
[mailto:redhat-list-bounces@redhat.com] On Behalf Of Tim P. Starrin
Sent: Wednesday, April 14, 2010 11:29 AM
To: General Red Hat Linux discussion list
Subject: 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@5-cent.us wrote:
> Steve wrote:
>
>> [mailto:redhat-list-bounces@redhat.com] On Behalf Of m.roth@5-cent.us
>> 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-a
>>> t-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@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Classification: UNCLASSIFIED
Caveats: NONE
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
04-14-2010, 06:02 PM
Yong Huang
vsize from within C++ (UNCLASSIFIED)
> Is it possible for a process to obtain information about itself
> (such as that provided by "top"), specifically vsize?
Steve,
I don't know C++. But isn't it a matter of open /proc/$$/stat as a regular file and read the vsize field?
If it's not limited to C++, just type the command:
$ ps -ovsz -p $$
VSZ
66228
Yong Huang
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list