home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!engr.uark.edu!tep
- From: tep@engr.uark.edu (Tim Peoples)
- Subject: Re: How To Get A List of Processes
- Message-ID: <1992Sep10.031742.2520@engr.uark.edu>
- Sender: netnews@engr.uark.edu (NetNews Administrator)
- Nntp-Posting-Host: engr.uark.edu
- Reply-To: tep@engr.uark.edu
- Organization: University of Arkansas
- Organiztion: University of Arkansas, Dept. of Computer Systems Engineering
- References: <1992Sep9.215721.5537@rtsg.mot.com>
- Distribution: usa
- Date: Thu, 10 Sep 1992 03:17:42 GMT
- Lines: 75
-
- rande@rtsg.mot.com (Kristian V. Rande) writes:
-
- >I'm trying to get a list of active processes from within some C code running
- >on a Sun 3/60. So far I've been having a lot of trouble, though, and I'm
- >hoping that somebody can give me some help.
- >
- >I believe I need to use the kernel library routines kvm_open(),
- >kvm_nextproc(), and kvm_close() to obtain structures of the type defined in
- >the header file <proc.h>. Unfortunately I get
- >
- > "cannot open /dev/mem: Permission denied" or
- >
- > "cannot open /dev/kmem: Permission denied"
- >
- >errors whenever I run my code. I think this is because I have no access to
- >these special files. An "ls -lgF" on these two files yields:
- >
- > crw-r----- 1 root kmem 3, 1 Jul 10 1990 /dev/kmem
- > crw-r----- 1 root kmem 3, 0 Aug 10 1990 /dev/mem
- >
- >I don't have root access, nor do I have kmem group access.
- >
- >Here's the test code fragment that makes the calls:
- >
- > if ( ( kd = kvm_open( NULL, NULL, NULL, O_RDONLY, "test" ) ) != NULL )
- > {
- > info = kvm_nextproc( kd );
- > printf( "pid = %d uid = %d\n", info->p_pid, info->p_uid );
- > kvm_close( kd );
- > }
- >
- >
- >My questions are:
- >
- > 1. Is there any way I can legitimately get around the mode restrictions
- > on "/dev/kmem" so that I can use kvm_nextproc()?
- >
-
- No.
-
- >
- > 2. Is there another way that I can get information about all of the
- > other active processes in the kernel?
- >
-
- No.
-
- >
- >Thanks for any help you can give me.
- >
-
- The only "legitimate" way to do this is to have your binary
- sgid kmem. And I guess the only way you can do that is with
- root access. I'm sure that if you explain to your SysAdmin
- what it is that you're doing that he will set it for you.
- If you have a lot of debugging to do and you have to re-compile
- a lot, then he might not like you very much. You see, every time
- you re-write the file you loose the sgid. Good luck.
-
- > ----------------------------------------------------------------------
- > Kris V. Rande "My opinions are my own."
- > Motorola Radio Telephone Systems Group
- > Arlington Heights, Illinois rande@rtsg.mot.com
- >
- --
-
- +--------------------------------------+-------------------------------------+
- | Tim Peoples | The time has come the hacker said |
- | tep@engr.uark.edu | to talk of many things, |
- | Dept. of Computer Systems Engineering| of simms and sockets and semaphores |
- | University of Arkansas, Fayetteville | of processes and pings.... |
- +--------------------------------------+-------------------------------------+
- | I need no disclaimer; nobody listens to what I have to say anyway!! |
- +----------------------------------------------------------------------------+
-
-