New Code! (But this one goes to 11! edition)
When I switched my server farm from Linux to FreeBSD (something I may have to revisit now that I've got nothing but FreeBSD machines without X11 at home) I abandoned most of the creeping features I'd been using on the Linux boxes (since most of these machines ran Mastodon, there weren't quite as many creeping features as you can find on the aggressively malignant tumors that make up a commercial Linux release, but there were one or two that made it into my codebase.)
Some of the more useful features had already been ported to the *BSDs, so it was merely a matter of a deathmatch or two in the Ports arena to get them loaded onto my systems, but when I did the last server upgrade (from 105 watts down to 35 watts, baby!) I left Ports off the install list so I could keep the root filesystem down to under half a gigabyte (the first Linux install on Pell fit onto a 40mb disk with room to spare), so I didn't get any of the prerequisites that you need to run or install anything from Linuxland. This meant no pstree, which is apparently wired into my finger memory these days.
About two months ago I made some preliminary pokes at pstree when I was writing my own version of who, but I must have lost interest somewhere around the point where I'd written the function that slurps process information in from /proc, makes it into a tree, then returns it in a tidy little linked list.
I only realized it was still floating around when I started tiding up $HOME on pell today at lunch and ran across a file titled trace. When I looked at it and realized it was the forlorn orphan of a hacking expedition, I decided that this was a good day to finish up the job.
Ta-Dah! It doesn't support some of the fancier options that the standard Linux one does, and I've cheerfully left out -l support and proper support for hierarchies more than 200 processes deep, but it's portable, if by "portable" you mean "compiles on Mastodon, FreeBSD 4.4, and FreeBSD 4.8" (it compiles on MacOS 10.0.4.x, but there isn't actually a /proc on that particular FreeBSD variant, so I'll need to figure out how to grovel through kernel memory to get the proc out before it will actually be useful there. I'd use kvm(3) but the manpage for kvm_getprocs(3) states, ominously, that these function calls "do not belong" there. The combination of Jordan Hubbard and Apple, Inc means that "do not belong" translates to "will vanish without warning as soon as you've gotten used to them," so I'm going to look for a better supported solution.)
But the code (a) works for me, (b) is small, (c) is BSD-licensed, and (d) took less than 4 hours to drag up to version 0.1. So it's New Code! for the bravehearted and suicidally foolhardy.