home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / programm / 4602 < prev    next >
Encoding:
Text File  |  1992-09-09  |  2.0 KB  |  58 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!ftpbox!mothost!white!rtsg.mot.com!rande
  3. From: rande@rtsg.mot.com (Kristian V. Rande)
  4. Subject: How To Get A List of Processes
  5. Message-ID: <1992Sep9.215721.5537@rtsg.mot.com>
  6. Sender: news@rtsg.mot.com
  7. Nntp-Posting-Host: prussian21
  8. Organization: Motorola Inc., Cellular Infrastructure Group
  9. Distribution: usa
  10. Date: Wed, 9 Sep 1992 21:57:21 GMT
  11. Lines: 45
  12.  
  13. I'm trying to get a list of active processes from within some C code running
  14. on a Sun 3/60.  So far I've been having a lot of trouble, though, and I'm
  15. hoping that somebody can give me some help.
  16.  
  17. I believe I need to use the kernel library routines kvm_open(),
  18. kvm_nextproc(), and kvm_close() to obtain structures of the type defined in
  19. the header file <proc.h>.  Unfortunately I get
  20.  
  21.     "cannot open /dev/mem: Permission denied" or
  22.  
  23.     "cannot open /dev/kmem:  Permission denied"
  24.  
  25. errors whenever I run my code.  I think this is because I have no access to
  26. these special files.  An "ls -lgF" on these two files yields:
  27.  
  28.    crw-r-----  1 root     kmem       3,   1 Jul 10  1990 /dev/kmem
  29.    crw-r-----  1 root     kmem       3,   0 Aug 10  1990 /dev/mem
  30.  
  31. I don't have root access, nor do I have kmem group access.
  32.  
  33. Here's the test code fragment that makes the calls:
  34.  
  35.    if ( ( kd = kvm_open( NULL, NULL, NULL, O_RDONLY, "test" ) ) != NULL )
  36.    {
  37.       info = kvm_nextproc( kd );
  38.       printf( "pid = %d  uid = %d\n", info->p_pid, info->p_uid );
  39.       kvm_close( kd );
  40.    }
  41.  
  42.  
  43. My questions are:
  44.  
  45.    1. Is there any way I can legitimately get around the mode restrictions
  46.       on "/dev/kmem" so that I can use kvm_nextproc()?
  47.  
  48.    2. Is there another way that I can get information about all of the
  49.       other active processes in the kernel?
  50.  
  51. Thanks for any help you can give me.
  52.  
  53.   ----------------------------------------------------------------------
  54.   Kris V. Rande                                "My opinions are my own."
  55.   Motorola Radio Telephone Systems Group
  56.   Arlington Heights, Illinois                         rande@rtsg.mot.com
  57.  
  58.