home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!ftpbox!mothost!white!rtsg.mot.com!rande
- From: rande@rtsg.mot.com (Kristian V. Rande)
- Subject: How To Get A List of Processes
- Message-ID: <1992Sep9.215721.5537@rtsg.mot.com>
- Sender: news@rtsg.mot.com
- Nntp-Posting-Host: prussian21
- Organization: Motorola Inc., Cellular Infrastructure Group
- Distribution: usa
- Date: Wed, 9 Sep 1992 21:57:21 GMT
- Lines: 45
-
- 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()?
-
- 2. Is there another way that I can get information about all of the
- other active processes in the kernel?
-
- Thanks for any help you can give me.
-
- ----------------------------------------------------------------------
- Kris V. Rande "My opinions are my own."
- Motorola Radio Telephone Systems Group
- Arlington Heights, Illinois rande@rtsg.mot.com
-
-