1827204 Members
2449 Online
109716 Solutions
New Discussion

process info.

 
SOLVED
Go to solution
RobertClark
Occasional Contributor

process info.

Can any one tell how to get process name from process id in HP. which field give this information.


#include
#include
#include
#include


int main( argc, argv )
int argc;
char** argv;
{

struct pst_status buf;
size_t psize;
size_t count;
int index;

index = getppid();
psize = sizeof( struct pst_status );
count = 0;

if ( pstat_getproc( &buf, psize, 0, index ) < 0 ) {

perror( "pstat_getproc" );
return -1;

}

printf( " Information %s\n", buf.u_comm);


return 0;

}
3 REPLIES 3
Peter Godron
Honored Contributor

Re: process info.

Robert,
may I suggest you reward the efforts of the people helping with your questions:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33

Your profiles shows you have not allocated points to any of the answers to your questions!


This thread may help with your current question:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=195283
Yogeeraj_1
Honored Contributor

Re: process info.

hi,

you may also have a look at "lsof"

hope this helps too!

kind regards
yogeerah
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Rory R Hammond
Trusted Contributor
Solution

Re: process info.

Looks like you mislabeled you name
buf.u_comm should be buf.pst_ucomm

I made a few changes but not many, I was able to compile and run the following:

#include
#include
#include
#include

main(argc, argv)
int argc ;
char **argv ;
{

struct pst_status buf;

size_t psize;
size_t count;
int index;

index= (int) getppid();
count=0;
if (pstat_getproc(&buf,sizeof(buf), (size_t)0,index) != -1)
{
(void) printf("Information Process id: %d Program Name: %s\n", index, buf.pst_ucomm);
}
else {
(void) perror("pstat_getpoc");
return -1;
}

return(0) ;
}



There are a 100 ways to do things and 97 of them are right