From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.redhat.com (mail.redhat.com [199.183.24.239]) by listman.redhat.com (Postfix) with ESMTP id 4D9C72F403 for ; Wed, 24 Jan 2001 16:07:59 -0500 (EST) Received: (from mail@localhost) by mail.redhat.com (8.11.0/8.8.7) id f0OL7jK00847 for axp-list@listman.redhat.com; Wed, 24 Jan 2001 16:07:45 -0500 Received: from zmamail05.zma.compaq.com (zmamail05.zma.compaq.com [161.114.64.105]) by mail.redhat.com (8.11.0/8.8.7) with ESMTP id f0OL7jd00840 for ; Wed, 24 Jan 2001 16:07:45 -0500 Received: by zmamail05.zma.compaq.com (Postfix, from userid 12345) id 4834F3334; Wed, 24 Jan 2001 16:07:52 -0500 (EST) Received: from ives.lkg.dec.com (ives.lkg.dec.com [16.24.240.4]) by zmamail05.zma.compaq.com (Postfix) with ESMTP id 17FF330A1; Wed, 24 Jan 2001 16:07:52 -0500 (EST) Received: by ives.lkg.dec.com (8.8.8/1.1.19.2/18May00-1129AM) id QAA13545; Wed, 24 Jan 2001 16:07:51 -0500 (EST) From: Bharadwaj Yadavalli Message-Id: <200101242107.QAA13545@ives.lkg.dec.com> Subject: Re: /proc/PID/stat To: axp-list@redhat.com Date: Wed, 24 Jan 2001 16:07:51 -0500 (EST) Cc: gatgul@voicenet.com In-Reply-To: <3A6F26CA.9023F7D5@voicenet.com> from "Uncle George" at Jan 24, 2001 02:02:34 PM X-Mailer: ELM [version 2.5 PL1] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0beta4 Precedence: bulk Reply-To: axp-list@redhat.com List-Id: Linux and Red Hat on Alpha processors From : Uncle George 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; }