Xref: utzoo comp.unix.wizards:10849 comp.unix.xenix:3202 comp.unix.questions:9076 comp.unix.microport:1465 Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!nrl-cmf!cmcl2!lanl!unm-la!unmvax!sleepy.unm.edu!mike From: mike@sleepy.unm.edu (Michael I. Bushnell) Newsgroups: comp.unix.wizards,comp.unix.xenix,comp.unix.questions,comp.unix.microport Subject: Re: process ids Keywords: utmp ps process id Message-ID: <1192@unmvax.unm.edu> Date: 2 Sep 88 06:43:08 GMT References: <171@ispi.UUCP> Sender: news@unmvax.unm.edu Reply-To: mike@sleepy.unm.edu.UUCP (Michael I. Bushnell) Organization: University of New Mexico, Albuquerque Lines: 32 In article <171@ispi.UUCP> jbayer@ispi.UUCP (id for use with uunet/usenet) writes: > > I have a need to be able to identify the parent of a process >which is executing on the system. The program which will be doing the >identification will not be either the owner, or even the same user. >However, it will have root privilages. The idea is to be able to kill >an entire process group with one kill(). I know it's available >somewhere since ps is able to display it. > > I have found an include file which apparently >is used by the system to keep track of this. I can find no reference to >it in any manual I have looked in. If you want to kill a process group, then kill with a negative argument will do that. If you just want the parent for another reason (to kill an entire process hierarchy, or whatever), then do the following: Using nlist(3), find the symbol _proc and _nproc in /vmunix. Read from /dev/kmem a longword from _proc and _nproc. _proc contains the address of the process table and _nproc contains the size. Then read the process table (it is sizeof(struct proc) * nproc) in size... Search one by one. Check each record to see if it is a real process (p_stat != 0). Then, check if it is the process you want and then look at its parent. -- N u m q u a m G l o r i a D e o Michael I. Bushnell HASA - "A" division mike@turing.unm.edu {ucbvax,gatech}!unmvax!turing.unm.edu!mike