Solved

C compilation program on on solaris

Posted on 2001-06-20
3
379 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops 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.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now