Operating System - HP-UX
1755534 Members
4237 Online
108834 Solutions
New Discussion юеВ

Re: pstat_getproc issue on 11iV3

 
NAGS
New Member

pstat_getproc issue on 11iV3

I am using following program to collect the current Heap usage... The same program work fine in HP11iV2.Some how the same program fails in 11iV3.

the pstat_getproc returns -1.

I am able to get pst_dsize,pst_tsize and pst_ssize.

what is the problem on 11iV3??

#include
#include
#include
#include
void main(void)
{
struct pst_status psinfo;
pid_t index = getpid();
fprintf(stderr,"\n%d\n",index);
if (pstat_getproc(&psinfo, sizeof(psinfo), (size_t)0, index) != -1)
{
printf("\nProcessHeap:%d\n ",psinfo.pst_dsize+psinfo.pst_tsize+psinfo.pst_ssize);
}
else
{
printf("\nFailed\n");
}
}
2 REPLIES 2
David Johns
Advisor

Re: pstat_getproc issue on 11iV3

Howdy NAGS:

The program worked for me on 11iV3, only change I made was to #include

I think the errno should be set when pstat_getproc fails. Try using the perror function in the else clause.

Regards,
-Dave
Dennis Handly
Acclaimed Contributor

Re: pstat_getproc issue on 11iV3

Your program isn't Standard:
warning #2951-D: return type of function "main" must be "int"
void main(void) {
warning #2223-D: function "getpid" declared implicitly
pid_t index = getpid();

Your format isn't correct: ProcessHeap:%ld

I'm not sure why you care about pst_tsize, this is just about free?

As David said you need to check errno.
Are you compiling with -D_PSTAT64?
If so, your format would be %lld.