Im trying to compile the following program:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/proc.h>
int main ( void )
{
pid_t jvmpid;
proc_t* jvmproc;
jvmpid = getpid();
printf( "I'm process %d\n", jvmpid );
jvmproc = (proc_t *) prfind(jvmpid);
return EXIT_SUCCESS;
}
but i got the error:
Undefined first referenced
symbol in file
prfind /var/tmp/ccRMZ7Tu.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
What library should i use for linking?
My ultimate goal is to have the process memory
What process information were you after?
If I want process information I use the following code (note this is on Solaris 2.7 on SPARC using the Sun CC compiler)
1) Find the PID of the process you are interested in using the getpid() function.
2) Open the file /proc/pid_number as read only obtaining a file descriptor - fd.
3) declare variables as below
prusage_t prusage;
prpsinfo_t prpsinfo;
4) You can then fill these two structs as follows
ioctl(fd,PIOCPSINFO,&prpsi
ioctl(fd,PIOCUSAGE,&prusag
5) Close the file fd.
You can then use the fields of the struct to get ps like and resource usage info re the process.
Cheers - Gavin