Solved

C compilation program on on solaris

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

856 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