dusan@osupyr.UUCP (Dusan Nedeljkovic) (12/15/86)
Does anyone have any clues as to how to access the "user" structure in <sys/user.h> ? I need to find information concerning the status of a users process for a C program I will be writting. Any help on where to find this information (or am I on the wrong track?) would be highly appreciated. Thanks in advance. Dusan. address: dusan%osupyr.uucp@osu-eddie.uucp
apn@nonvon.UUCP (apn) (12/26/86)
In article <96@osupyr.UUCP>, dusan@osupyr.UUCP (Dusan Nedeljkovic) writes: > Does anyone have any clues as to how to access the "user" structure > in <sys/user.h> ? > > I need to find information concerning the status of a users process > for a C program I will be writting. Any help on where to find this > information (or am I on the wrong track?) would be highly appreciated. > > Reading user struct from C program. a simple outline: 1] find your process descriptor table entry in ram by reading from /dev/mem and filling proc structure ( see <sys/proc.h> ) 2] determine from the entry that is yours, what the address of your process is and what device it is on at the moment. Should either /dev/mem or /dev/swap or for those lucky few of us /dev/swmem address of your user struct should be determined from something like : (again, this is highly dep. on your CPU, MMU, etc) (this is for 68k w/ 68451 MMU ) addr = ctob((long) proc_p.addr) for /dev/swap addr = proc.p_addr + swplo << 9; for /dev/swmem 3] seek to addr in /dev/(fill in appropriate device) and read something the size of your user structure 4] <done> Note that all this requires read access to /dev/mem, etc. And thus may defeat your purpose. Take this only as an outline. Mileage will vary considerable with flavor of UNIX. This was from sV. Other than those caveats.... I hope this is of some help. uucp: ptsfa!nonvon!apn -- UUCP: ihnp4!ptsfa!nonvon!apn 100 Drakes Landing Road GreenBrae, CA 94904 +1 415 461 4655 {* War does not determine who is right or wrong........ only who is left *} {* Only those who attempt the absurd ... will achieve the impossible *} {* I think... I think it's in my basement... Let me go upstairs and check. *} {* -escher *} {* System down for P.M. until further notice *}
chris@mimsy.UUCP (Chris Torek) (12/30/86)
In article <96@osupyr.UUCP> dusan@osupyr.UUCP (Dusan Nedeljkovic) writes: >Does anyone have any clues as to how to access the "user" structure >in <sys/user.h> ? For anyone with source, the answer is `do what ``ps'' does'. For those on a 4BSD Vax, there is a terribly hacky shortcut if you want to read only your own user structure. It is already in your address space. #include <sys/param.h> #include <sys/dir.h> #include <sys/user.h> main() { struct user u; u = *(struct user *)(0x80000000 - UPAGES*NBPG); printf("%d %d\n", u.u_uid, u.u_gid); } `Undocumented features are subject to change without notice.' -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu