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

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!engr.uark.edu!tep
  3. From: tep@engr.uark.edu (Tim Peoples)
  4. Subject: Re: How To Get A List of Processes
  5. Message-ID: <1992Sep10.031742.2520@engr.uark.edu>
  6. Sender: netnews@engr.uark.edu (NetNews Administrator)
  7. Nntp-Posting-Host: engr.uark.edu
  8. Reply-To: tep@engr.uark.edu
  9. Organization: University of Arkansas
  10. Organiztion: University of Arkansas, Dept. of Computer Systems Engineering
  11. References: <1992Sep9.215721.5537@rtsg.mot.com>
  12. Distribution: usa
  13. Date: Thu, 10 Sep 1992 03:17:42 GMT
  14. Lines: 75
  15.  
  16. rande@rtsg.mot.com (Kristian V. Rande) writes:
  17.  
  18. >I'm trying to get a list of active processes from within some C code running
  19. >on a Sun 3/60.  So far I've been having a lot of trouble, though, and I'm
  20. >hoping that somebody can give me some help.
  21. >
  22. >I believe I need to use the kernel library routines kvm_open(),
  23. >kvm_nextproc(), and kvm_close() to obtain structures of the type defined in
  24. >the header file <proc.h>.  Unfortunately I get
  25. >
  26. >    "cannot open /dev/mem: Permission denied" or
  27. >
  28. >    "cannot open /dev/kmem:  Permission denied"
  29. >
  30. >errors whenever I run my code.  I think this is because I have no access to
  31. >these special files.  An "ls -lgF" on these two files yields:
  32. >
  33. >   crw-r-----  1 root     kmem       3,   1 Jul 10  1990 /dev/kmem
  34. >   crw-r-----  1 root     kmem       3,   0 Aug 10  1990 /dev/mem
  35. >
  36. >I don't have root access, nor do I have kmem group access.
  37. >
  38. >Here's the test code fragment that makes the calls:
  39. >
  40. >   if ( ( kd = kvm_open( NULL, NULL, NULL, O_RDONLY, "test" ) ) != NULL )
  41. >   {
  42. >      info = kvm_nextproc( kd );
  43. >      printf( "pid = %d  uid = %d\n", info->p_pid, info->p_uid );
  44. >      kvm_close( kd );
  45. >   }
  46. >
  47. >
  48. >My questions are:
  49. >
  50. >   1. Is there any way I can legitimately get around the mode restrictions
  51. >      on "/dev/kmem" so that I can use kvm_nextproc()?
  52. >
  53.  
  54. No.
  55.  
  56. >
  57. >   2. Is there another way that I can get information about all of the
  58. >      other active processes in the kernel?
  59. >
  60.  
  61. No.
  62.  
  63. >
  64. >Thanks for any help you can give me.
  65. >
  66.  
  67.    The only "legitimate" way to do this is to have your binary 
  68. sgid kmem.  And I guess the only way you can do that is with
  69. root access.  I'm sure that if you explain to your SysAdmin
  70. what it is that you're doing that he will set it for you.
  71. If you have a lot of debugging to do and you have to re-compile
  72. a lot, then he might not like you very much.  You see, every time
  73. you re-write the file you loose the sgid.  Good luck.
  74.  
  75. >  ----------------------------------------------------------------------
  76. >  Kris V. Rande                                "My opinions are my own."
  77. >  Motorola Radio Telephone Systems Group
  78. >  Arlington Heights, Illinois                         rande@rtsg.mot.com
  79. >
  80. -- 
  81.  
  82. +--------------------------------------+-------------------------------------+
  83. | Tim Peoples                          | The time has come the hacker said   |
  84. | tep@engr.uark.edu                    | to talk of many things,             |
  85. | Dept. of Computer Systems Engineering| of simms and sockets and semaphores |
  86. | University of Arkansas, Fayetteville | of processes and pings....          |
  87. +--------------------------------------+-------------------------------------+
  88. |    I need no disclaimer; nobody listens to what I have to say anyway!!     |
  89. +----------------------------------------------------------------------------+
  90.  
  91.