Path: utzoo!attcan!uunet!convex!killer!vector!rpp386!jfh From: jfh@rpp386.UUCP (John F. Haugh II) Newsgroups: comp.unix.wizards Subject: Re: Is it possible to get hold of a process's Process control Block given Message-ID: <5007@rpp386.UUCP> Date: 5 Aug 88 14:07:27 GMT References: <8807140043.ab12588@SEM.BRL.ARPA> <429@alice.marlow.uucp> Reply-To: jfh@rpp386.UUCP (The Beach Bum) Organization: Big "D" Home for Wayward Hackers Lines: 61 In article <429@alice.marlow.uucp> fox@marlow.UUCP (Paul Fox) writes: >That answers your question (albeit badly)...can anybody answer >mine... I am trying to write/port the BSD 'top' utility >posted to usenet sometime ago, to Unix V.3. who knows ... the relevant area of the process table entry is p_addr. on some systems this is a union, with one part for the core address, and another for the swap address. select the appropriate one by looking at p_stat. if you post your source (or mail me a copy) i should be able to get it ported to sco xenix in 10 or 15 minutes ;-) below is my solution to finding a user page. it is cut from a soon to be posted crash command. ignore most of the cruft. the includes should give you an idea of where to look for hints as to how to get this to work. ----- crash/user.c ----- #include #include #include #include #include #include #include #include #include #include #include #include #include "crash.h" findu (proc, slot, user) struct proc *proc; int slot; struct user *user; { struct proc *procs = (struct proc *) namelist[NM_PROC].xl_value; long swapaddr; int i; if ((proc->p_flag & (SSWAP|SSPART)) || ! (proc->p_flag & SLOAD)) { swapaddr = proc->p_addr[0].te_frameno * NBPC; l_lseek (swapfd, swapaddr, 0); r_read (swapfd, user, sizeof *user); } else { l_lseek (memfd, proc->p_addr[0].te_frameno * NBPC, 0); r_read (memfd, user, sizeof *user); } if (user->u_procp - procs == slot) return (1); else return (0); } /* rest deleted */ -- John F. Haugh II +--------- Cute Chocolate Quote --------- HASA, "S" Division | "USENET should not be confused with UUCP: killer!rpp386!jfh | something that matters, like CHOCOLATE" DOMAIN: jfh@rpp386.uucp | -- apologizes to Dennis O'Connor