Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Easily view process heirarchy UNIX
Sometimes you get a process in your top listing, and you don't know what launched it. Normally you would have to launch ps and match up the PPID with another process's PID. The pstree utility will do this work for you, and draw the ps listing as a pretty tree.

For example, at startup time, init launches the WindowServer, which launches the dock:
-+- 00001 root /sbin/init
|--- 00041 root kextd
|--- 00075 ben /System/Library/Frameworks/ApplicationServices...
|-+- 00077 ben /System/Library/CoreServices/WindowServer
| |--- 00333 ben /System/Library/CoreServices/
| |--- 00334 ben /System/Library/CoreServices/SystemUIServer...
[Lines trimmed to narrow the display width]

pstree is in Fink's stable cvs, so use fink selfupdate-cvs; fink install pstree to install it.
  • Currently 3.67 / 5
  You rated: 4 / 5 (3 votes cast)

Easily view process heirarchy | 6 comments | Create New Account
Click here to return to the 'Easily view process heirarchy' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Compile without fink
Authored by: oeyvind on May 24, '02 12:19:05AM

If you don\'t know what to use fink, for one reason or another... edit pstree.c, look at line 168:

#elif defined(__FreeBSD__) /* FreeBSD */

change it to:

#elif defined(__FreeBSD__) || defined(__APPLE__) /* FreeBSD */

Save the changes and compile as per README.

[ Reply to This | # ]
Compile without fink
Authored by: magor on May 24, '02 03:21:58AM

Thanks, my fink did not list the pstree as available. Used your info to compile it. Works great.

[ Reply to This | # ]
Compile without fink
Authored by: bhines on May 24, '02 07:35:00AM

Er, if you "fink selfupdate-cvs", like the TIP SAYS, it will list as available.

[ Reply to This | # ]
Compile without fink
Authored by: babbage on May 25, '02 01:11:33PM

Nah, that's too easy, Ben. Must go munge the source manually! :-)

[ Reply to This | # ]
Authored by: eno on May 25, '02 10:03:04AM

What a cool little program. Thanks for the tip!

[ Reply to This | # ]
Authored by: hayne on Jul 04, '03 06:21:17PM

It's even cooler if you use the "-g 2" option:
pstree -g 2

The "-w" option is useful if you want to see the full names of processes, so what I have pstree aliased to is:
pstree -g 2 -w

[ Reply to This | # ]