The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Reading the process table

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
Reading the process table Posted: Feb 21, 2005 12:37 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: Reading the process table
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
A while back I ported Dan Urist's Proc::ProcessTable Perl module to Ruby, in a package called sys-proctable. In the process (no pun intended) I learned quite a bit about how different operating systems let you get at process table information, or not.

It helped that I had access to a somewhat diverse group of operating systems. These included Solaris, anywhere from 2.5.1 to 2.9, Windows 2000 and XP, HP-UX 10 and 11, FreeBSD and Linux. This isn't generally true any more, however. I haven't touched AIX, Irix or OS X yet.

I made several tweaks and adjustments in Dan's code to suit our own needs. Getting past the 80 character limit for the command string on Solaris, for example, took some figuring out (thanks, Java command line strings). I learned lots of little things like this on other platforms as well.

Some platforms were nice about providing libraries for accessing process table information. I found that HP-UX, believe it or not, had the easiest API. A close second is probably lkvm on FreeBSD. Windows was the most interesting, providing up to seven (!) approaches for getting process information, one of which is not officially documented. In the end, I settled on a (as yet unreleased) pure Ruby version that used OLE + WMI.

The tried and true method of reading /proc isn't as portable as you might think, either. On Linux and the various BSD flavors you're reading plain text. On Solaris you're generally reading packed data structures and using libraries provided by Sun to unravel the data. Compound this with the fact that BSD users tend to leave /proc unmounted as a security precaution and things get interesting. The only solution there is to resort to lkvm, but that requires special privileges. Also, it isn't supported on Linux.

All of this had me thinking how nice it would be if there were some sort of POSIX standard that stated, "Thou shallt get process table information this way". But, I think I have to accept the fact that it's just never gonna happen. Too many differences not only in kernel architecture, but also philosophy. Witness the OpenBSD philosophy on /proc, for example.

Interestingly, it appears that the lkvm approach was an early attempt to solve this issue, but the compatibility never appears to have extended past Solaris and BSD, and it lasted about 5 minutes. There is no kvm_getprocs() on Solaris, for example. So much for that plan.

Anyway, I should have release 0.7.0 out within a month or so. This release includes the revamped Windows version, which I couldn't release until 1.8.2 was finally out due to bugs in earlier versions of the OLE wrapper. It will also contain prusage data for Solaris.

Read: Reading the process table

Topic: New Typo release Previous Topic   Next Topic Topic: new mascot for parsetree!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use