From: petert@persied.zk3.dec.com (Peter Thompson)
Subject: Re: /proc fs - anyone had any success reading
Date: 26 Aug 1994 15:17:27 GMT [thread overview]
Message-ID: <33l127$uv@jac.zko.dec.com> (raw)
In-Reply-To: 777018625snz@spclmway.demon.co.uk
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 <stdio.h>
#include <fcntl.h>
#include <sys/proc.h>
#include <sys/procfs.h>
#include <sys/types.h>
#include <sys/ioctl.h>
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
prev parent reply other threads:[~1994-08-26 15:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-08-16 6:30 /proc fs - anyone had any success reading Gareth Owen
1994-08-26 15:17 ` Peter Thompson [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox