Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C compilation program on on solaris

Posted on 2001-06-20
3
Medium Priority
?
421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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 and use switch statements 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.

670 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