From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,5c1b5c77feab2f8 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-08-26 08:51:12 PST Path: bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!news.kei.com!yeshua.marcam.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!swrinde!elroy.jpl.nasa.gov!ames!decwrl!pa.dec.com!jac.zko.dec.com!persied.zk3.dec.com!petert From: petert@persied.zk3.dec.com (Peter Thompson) Newsgroups: comp.unix.osf.osf1 Subject: Re: /proc fs - anyone had any success reading Date: 26 Aug 1994 15:17:27 GMT Organization: Digital Equipment Corporation Distribution: world Message-ID: <33l127$uv@jac.zko.dec.com> References: <777018625snz@spclmway.demon.co.uk> NNTP-Posting-Host: persied.zk3.dec.com Well, I use it all the time (as I'm responsible for dbx here) and it does work pretty well. Not to say that we haven't run into a few bugs from time to time, but who hasn't ;-) Here's a test program that should illustrate briefly how to set things up. The presumptions here are that the program is invoked with the pid of a currently running process, and that the process is owned by the invoker, or the invoker has su access. Oh yeah, /proc has to be mounted, else this don't work at all. Oops, now I see I mentioned that in the test itself. Silly me. #include #include #include #include #include #include main (argc, argv) int argc; char **argv; { /* assume that /proc is mounted and user specified the pid of the * running process. */ char pidname[32]; int fd; struct prstatus prstat; sprintf(pidname, "/proc/%s", argv[1]); fd = open(pidname, O_RDONLY | O_NDELAY); ioctl(fd, PIOCSTATUS, &prstat); printf("The pc at the time of the sample is 0x%lx\n", prstat.pr_reg.regs[31]); close(fd); exit(0); } PeterT