Solved

C compilation program on on solaris

Posted on 2001-06-20
3
398 Views
Last Modified: 2013-12-05
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



0
Comment
Question by:Kobold
  • 2
3 Comments
 
LVL 4

Expert Comment

by:newmang
ID: 6213021
What is prfind? I did a man page on it with no results, what is it supposed to do?

Cheers - Gavin
0
 
LVL 3

Author Comment

by:Kobold
ID: 6214321
Its suppose to return an handle on a process, and i can use this handle to retrieve process information.
0
 
LVL 4

Accepted Solution

by:
newmang earned 50 total points
ID: 6216498
Oh - its just that I can't find it on my Solaris system using the Sun CC compiler.

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,&prpsinfo);
ioctl(fd,PIOCUSAGE,&prusage);
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
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question