Solved

C compilation program on on solaris

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

911 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

15 Experts available now in Live!

Get 1:1 Help Now