From: Bharadwaj Yadavalli <sby@ives.lkg.dec.com>
To: axp-list@redhat.com
Cc: gatgul@voicenet.com
Subject: Re: /proc/PID/stat
Date: Wed, 24 Jan 2001 16:07:51 -0500 (EST) [thread overview]
Message-ID: <200101242107.QAA13545@ives.lkg.dec.com> (raw)
In-Reply-To: <3A6F26CA.9023F7D5@voicenet.com> from "Uncle George" at Jan 24, 2001 02:02:34 PM
From : Uncle George <gatgul@voicenet.com>
Date : Wed Jan 24 14:02:34 2001
Its interesting, but its not 64bit literate. For example the integer
stack pointer! The num of signals on alpha/linux is 64. Int will just
hold 32 of them ( & they certainly will not hold the SIG's 32 & 33 used
py the pthread system :-{ ).
What I wanted was a pgm that said
pc=0x45, ps=0x46908, sp=0x20012301234 .
Now I know what happened.... I sent out an old and incorrect
version. Here is the correct one. Apologies for the mistake.
Bharadwaj
typedef struct statstruct_proc {
int pid; /** %d The process id. **/
char exName [_POSIX_PATH_MAX]; /** %s The filename of the executable **/
char state; /** 1 **/ /** %c R is running, S is sleeping,
D is sleeping in an uninterruptible wait,
Z is zombie, T is traced or stopped **/
int euid, /** %d effective user id **/
egid; /** %d effective group id */
int ppid; /** %d The pid of the parent. **/
int pgrp; /** %d The pgrp of the process. **/
int session; /** %d The session id of the process. **/
unsigned long tty; /** %lu The tty the process uses **/
unsigned long tpgid; /** %lu **/
unsigned long flags; /** %lu The flags of the process. **/
unsigned long minflt; /** %lu The number of minor faults **/
unsigned long cminflt; /** %lu The number of minor faults with childs **/
unsigned long majflt; /** %lu The number of major faults **/
unsigned long cmajflt; /** %lu The number of major faults with childs **/
long utime; /** %ld user mode jiffies **/
long stime; /** %ld kernel mode jiffies **/
long cutime; /** %ld user mode jiffies with childs **/
long cstime; /** %ld kernel mode jiffies with childs **/
long counter; /** %ld process's next timeslice **/
long priority; /** %ld the standard nice value, plus fifteen **/
unsigned long timeout; /** %lu The time in jiffies of the next timeout **/
unsigned long itrealvalue; /** %lu The time before the next SIGALRM is sent to the process **/
long starttime; /** 20 **/ /** %ld Time the process started after system boot **/
unsigned long vsize; /** %lu Virtual memory size **/
unsigned long rss; /** %lu Resident Set Size **/
unsigned long rlim; /** %lu Current limit in bytes on the rss **/
unsigned long startcode; /** %lu The address above which program text can run **/
unsigned long endcode; /** %lu The address below which program text can run **/
unsigned long startstack; /** %lu The address of the start of the stack **/
unsigned long kstkesp; /** %lu The current value of ESP **/
unsigned long kstkeip; /** %lu The current value of EIP **/
unsigned long signal; /** %lu The bitmap of pending signals **/
unsigned long blocked; /** 30 **/ /** %lu The bitmap of blocked signals **/
unsigned long sigignore; /** %lu The bitmap of ignored signals **/
unsigned long sigcatch; /** %lu The bitmap of catched signals **/
unsigned long wchan; /** 33 **/ /** %lu **/
/* Ignoring 4 more fields that get printed on 2.2.17, for now */
} procinfo;
int get_proc_info(pid_t pid, procinfo * pinfo)
{
char szFileName [_POSIX_PATH_MAX],
szStatStr [2048],
*s, *t;
FILE *fp;
struct stat st;
if (pinfo == NULL) {
errno = EINVAL;
return -1;
}
sprintf (szFileName, "/proc/%u/stat", (unsigned) pid);
if (access(szFileName, R_OK) == -1) {
return (pinfo->pid = -1);
}
if (stat(szFileName, &st) == -1) {
pinfo->euid = st.st_uid;
pinfo->egid = st.st_gid;
} else {
pinfo->euid = pinfo->egid = -1;
}
if ((fp = fopen (szFileName, "r")) == NULL) {
return (pinfo->pid = -1);
}
if ((s = fgets (szStatStr, 2048, fp)) == NULL) {
fclose (fp);
return (pinfo->pid = -1);
}
sscanf (szStatStr, "%u", &(pinfo->pid));
s = strchr (szStatStr, '(') + 1;
t = strchr (szStatStr, ')');
strncpy (pinfo->exName, s, t - s);
pinfo->exName [t - s] = '\0';
/* out of fs/proc/array.c
sprintf(t + 2, "%c %d %d %d %d %d %lu %lu "
"%lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld "
"%lu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d");
*/
sscanf (t + 2, "%c %d %d %d %d %d %lu %lu %lu %lu "
/* 1 2 3 4 5 6 7 8 9 10 */
"%lu %lu %lu %ld %ld %ld %ld %lu %ld %lu "
/*11 12 13 14 15 16 17 18 19 20 */
"%lu %ld %lu %lu %lu %lu %lu %lu %lu %lu "
/*21 22 23 24 25 26 27 28 29 30 */
"%lu %lu %lu",
/*31 32 33 */
&(pinfo->state),
&(pinfo->ppid),
&(pinfo->pgrp),
&(pinfo->session),
&(pinfo->tty),
&(pinfo->tpgid),
&(pinfo->flags),
&(pinfo->minflt),
&(pinfo->cminflt),
&(pinfo->majflt),
&(pinfo->cmajflt),
&(pinfo->utime),
&(pinfo->stime),
&(pinfo->cutime),
&(pinfo->cstime),
&(pinfo->counter),
&(pinfo->priority),
&(pinfo->timeout),
&(pinfo->itrealvalue),
&(pinfo->starttime),
&(pinfo->vsize),
&(pinfo->rss),
&(pinfo->rlim),
&(pinfo->startcode),
&(pinfo->endcode),
&(pinfo->startstack),
&(pinfo->kstkesp),
&(pinfo->kstkeip),
&(pinfo->signal),
&(pinfo->blocked),
&(pinfo->sigignore),
&(pinfo->sigcatch),
&(pinfo->wchan));
fclose (fp);
return 0;
}
prev parent reply other threads:[~2001-01-24 21:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-24 1:11 /proc/PID/stat Uncle George
2001-01-24 17:39 ` /proc/PID/stat Bharadwaj Yadavalli
2001-01-24 19:02 ` /proc/PID/stat Uncle George
2001-01-24 20:21 ` /proc/PID/stat Bharadwaj Yadavalli
2001-01-24 21:07 ` Bharadwaj Yadavalli [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox