pstree

Pstree is a clone of the standard Linux pstree command, which displays process information in a heirarchical fashion. It builds and runs on SLS linux, RedHat linux (tested rhel3), FreeBSD (tested on 4.4 & 4.8,) and MacOS 10.0.4. Unlike the standard pstree, it uses either sysctl() [macOS], kvm_getprocs() [FreeBSD 4.?] or /proc [SLS linux] as needed.

pstree is free software; it is released under a BSD-style license that allows you to do as you wish with it as long as you don’t attempt to claim it as your own work.

To install pstree, do

$ ./configure.sh
$ make
then become root and do
# make install

If pstree needs to use sysctl() or kvm_getprocs() to read process information, it will be installed as a setuid process to allow it to read all of the process data.

Source Code

v0.5
basename() on the BSDs uses a static buffer to hold the new basename. This makes it pretty much impossible to use basename() for anything non-trivial unless you surround it with a strdup() wrapper. The 0.5 release corrects this misfeature by replacing basename() with a local function.
v0.4
  1. Internal range checking to take away the fun of having a setuid program possibly doing a stack overrun and giving J. Random. Hacker a free doorway to root privileges.
  2. Implement the -A option (like -a, except it shows, if possible, the full pathname to the program name.)
  3. Try to automatically configure whether to look at /proc or use sysctl() or kvm_getprocs().
v0.3
A README file, support for the -l option, automatic window width detection, more work on sysctl() vs kvm_getprocs() so that it will work on FreeBSD versions that don’t support kvm_getprocs() anymore.
v0.2
The first release that works on more than one platform; 0.2 works on FreeBSD 4.x and SLS linux, and doesn’t have an embarrassing number of misfeatures and/or bugs.
v0.1
The initial release, which almost works on SLS linux.