|
Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006
Novice C : solaris function under any relevant information available to the process?
For example : process name, process pid, share CPU/Memory process, start time, running and so on.
Thank you. |
Novice C : solaris function under any relevant information available to the process?
The getpid () function returns the process ID of the calling process.
For other information, you can try : getrusage
NAME
Getrusage-get information about resource utilization
SYNOPSIS
#include "Sys/resource.h>;
Int getrusage (int who, struct rusage *r_usage);
Refer to the man page for detail usage of func. |
Novice C : solaris function under any relevant information available to the process?
I think of all information systems, which are under the process.
Getpid () can access the current process pid.
Who Banggemang ah? |
Novice C : solaris function under any relevant information available to the process?
/proc Read the paper every process in the catalog has a corresponding document.
[code]
Fd = open (path, O_RDONLY);
Ioctl (fd, PIOCPSINFO, &procinfo);
Close (fd);
[/code] |
Novice C : solaris function under any relevant information available to the process?
Whether or not that specific point, a corresponding list /proc, each process, but I looked at them, are binary file, no text documents, the how? |
Novice C : solaris function under any relevant information available to the process?
Invoke read () or fread () to get the [.
You can refer to gdb 's very clear src for usage. |
Novice C : solaris function under any relevant information available to the process?
With the Shell
Cesar R 10 5 |
Novice C : solaris function under any relevant information available to the process?
No. /psinfo /proc/ process of reading the document.
I used to tell you that the function
Ioctl (fd, PIOCPSINFO, &procinfo);
Procinfo look at the structure in the know. |
Novice C : solaris function under any relevant information available to the process?
Write a simple procedure not perfect
LEAVES OF 13 SPECIES OF LAURACEAE Usage : procedure "pid>;
*/
#include "Stdio.h>;
#include "Unistd.h>;
#include "Stropts.h>;
#include "Sys/ioctl.h>;
#include "Sys/old_procfs.h>;
#include "Sys/types.h>;
#include "Sys/stat.h>;
#include "Fcntl.h>;
#include "Errno.h>;
Main (int argc, char **argv)
{
Int fd;
Char path[32];
Prpsinfo_t procinfo;
Snprintf (path,32 "/proc/%s" argv[1]);
Fd = open (path, O_RDONLY);
Printf ( "fd = %d\n" fd);
If (fd "0) (
Fprintf (stderr, "open %s error:%s\n" path, strerror (errno));
Close (fd);
Exit (1);
}
Ioctl (fd, PIOCPSINFO, &procinfo);
Printf ( "status=%c\n" procinfo.pr_sname);
Printf ( "zomb = %c\n" procinfo.pr_zomb); //if> 0, zomb
Printf ( "nice = %c\n" procinfo.pr_nice);
Printf ( "uid = %d\n" procinfo.pr_uid);
Printf ( "Forty = %d\n" procinfo.pr_gid);
Printf ( "pid = %d\n" procinfo.pr_pid);
Printf ( "ppid = %d\n" procinfo.pr_ppid);
Printf ( "group leader = %d\n" procinfo.pr_pgrp);
Printf ( "sid = %d\n" procinfo.pr_sid);
Printf ( "start time = %d ns\n" procinfo.pr_start.tv_sec*10^9 + procinfo.pr_sta
Rt.tv_nsec);
Printf ( "user and system time %d ns\n =" + procin procinfo.pr_time.tv_sec*10^9
Fo.pr_time.tv_nsec);
Printf ( "priority = %d\n" procinfo.pr_pri); //high Value = high pri
Printf ( "tty = %d\n" procinfo.pr_ottydev);
Printf ( "used cpu = %d\%\n" procinfo.pr_pctcpu);
Printf ( "used mem = %d\%\n" procinfo.pr_pctmem);
Close (fd);
} |
| |