Can someone tell me how I would make a process tree with the following data:
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 0 1 0 0 80 0 - 764 select ? 00:00:01 init
5 S 0 2 0 0 75 -5 - 0 kthrea ? 00:00:00 kthreadd
1 S 0 3 2 0 -40 - - 0 migrat ? 00:00:00 migration/0
1 S 0 4 2 0 75 -5 - 0 ksofti ? 00:00:00 ksoftirqd/0
5 S 0 5 2 0 -40 - - 0 watchd ? 00:00:00 watchdog/0
1 S 0 6 2 0 75 -5 - 0 worker ? 00:00:00 events/0
1 S 0 7 2 0 75 -5 - 0 worker ? 00:00:00 khelper
1 S 0 46 2 0 75 -5 - 0 worker ? 00:00:00 kintegrityd/0
1 S 0 48 2 0 75 -5 - 0 worker ? 00:00:00 kblockd/0
1 S 0 50 2 0 75 -5 - 0 worker ? 00:00:00 kacpid
1 S 0 51 2 0 75 -5 - 0 worker ? 00:00:00 kacpi_notify
1 S 0 129 2 0 75 -5 - 0 worker ? 00:00:00 cqueue
1 S 0 133 2 0 75 -5 - 0 serio_ ? 00:00:00 kseriod
1 S 0 167 2 0 80 0 - 0 pdflus ? 00:00:00 pdflush
1 S 0 168 2 0 80 0 - 0 pdflus ? 00:00:00 pdflush
1 S 0 169 2 0 75 -5 - 0 kswapd ? 00:00:03 kswapd0
1 S 0 211 2 0 75 -5 - 0 worker ? 00:00:00 aio/0
1 S 0 1181 2 0 75 -5 - 0 worker ? 00:00:00 ksuspend_usbd
1 S 0 1184 2 0 75 -5 - 0 hub_th ? 00:00:00 khubd
1 S 0 1199 2 0 75 -5 - 0 hpsbpk ? 00:00:00 khpsbpkt
1 S 0 1210 2 0 75 -5 - 0 worker ? 00:00:00 ata/0
1 S 0 1213 2 0 75 -5 - 0 worker ? 00:00:00 ata_aux
1 S 0 1940 2 0 75 -5 - 0 nodemg ? 00:00:00 knodemgrd_0
1 S 0 1944 2 0 75 -5 - 0 scsi_e ? 00:00:00 scsi_eh_0
1 S 0 1945 2 0 75 -5 - 0 scsi_e ? 00:00:00 scsi_eh_1
1 S 0 2247 2 0 75 -5 - 0 worker ? 00:00:00 aufsd
1 S 0 2249 2 0 75 -5 - 0 worker ? 00:00:00 aufsd
1 S 0 2250 2 0 75 -5 - 0 worker ? 00:00:00 aufsd
1 S 0 2251 2 0 75 -5 - 0 worker ? 00:00:00 aufsd
1 S 0 2284 2 0 60 -20 - 0 loop_t ? 00:00:03 loop0
5 S 0 4075 1 0 76 -4 - 609 select ? 00:00:00 udevd
1 S 0 4295 2 0 75 -5 - 0 worker ? 00:00:00 kpsmoused
1 S 0 4777 2 0 75 -5 - 0 pccard ? 00:00:00 pccardd
1 S 0 4779 2 0 75 -5 - 0 worker ? 00:00:00 ipw2100/0
4 S 0 6003 1 0 80 0 - 739 wait tty4 00:00:00 login
4 S 0 6006 1 0 80 0 - 739 wait tty5 00:00:00 login
4 S 0 6014 1 0 80 0 - 739 wait tty2 00:00:00 login
4 S 999 6017 6003 0 80 0 - 1440 read_c tty4 00:00:00 bash
4 S 999 6018 6006 0 80 0 - 1440 read_c tty5 00:00:00 bash
4 S 0 6019 1 0 80 0 - 739 wait tty3 00:00:00 login
4 S 999 6020 6014 0 80 0 - 1440 read_c tty2 00:00:00 bash
4 S 0 6024 1 0 80 0 - 739 wait tty6 00:00:00 login
4 S 999 6027 6019 0 80 0 - 1440 read_c tty3 00:00:00 bash
4 S 999 6028 6024 0 80 0 - 1440 read_c tty6 00:00:00 bash
1 S 0 6289 1 0 80 0 - 576 poll ? 00:00:00 acpid
1 S 0 6323 2 0 75 -5 - 0 worker ? 00:00:00 kondemand/0
5 S 101 6403 1 0 80 0 - 503 select ? 00:00:00 syslogd
4 S 0 6456 1 0 80 0 - 485 syslog ? 00:00:00 dd
1 S 102 6458 1 0 80 0 - 890 pipe_w ? 00:00:00 klogd
5 S 108 6481 1 0 80 0 - 757 poll ? 00:00:01 dbus-daemon
5 S 110 6503 1 0 80 0 - 722 poll ? 00:00:00 avahi-daemon
1 S 110 6504 6503 0 80 0 - 722 unix_s ? 00:00:00 avahi-daemon
5 S 0 6552 1 0 80 0 - 1602 ep_pol ? 00:00:00 cupsd
5 S 111 6630 1 0 80 0 - 1605 poll ? 00:00:01 hald
5 S 0 6633 1 0 80 0 - 4097 poll ? 00:00:00 console-kit-da
0 S 0 6696 6630 0 80 0 - 841 poll ? 00:00:00 hald-runner
4 S 0 6716 6696 0 80 0 - 1302 poll ? 00:00:00 hald-addon-del
0 S 0 6725 6696 0 80 0 - 859 poll ? 00:00:00 hald-addon-inp
0 S 0 6729 6696 0 80 0 - 862 poll ? 00:00:00 hald-addon-cpu
4 S 111 6730 6696 0 80 0 - 574 unix_s ? 00:00:00 hald-addon-acp
4 S 0 6739 6696 0 80 0 - 860 poll ? 00:00:00 hald-addon-sto
5 S 0 6785 1 0 80 0 - 872 poll ? 00:00:00 bluetoothd
1 S 0 6793 2 0 75 -5 - 0 worker ? 00:00:00 btaddconn
1 S 0 6795 2 0 75 -5 - 0 worker ? 00:00:00 btdelconn
5 S 0 6806 2 0 70 -10 - 0 rfcomm ? 00:00:00 krfcommd
5 S 0 6842 1 0 80 0 - 3688 poll ? 00:00:01 NetworkManager
4 S 0 6852 1 0 80 0 - 1060 select ? 00:00:00 wpa_supplicant
4 S 0 6854 1 0 80 0 - 1694 poll ? 00:00:00 nm-system-sett
5 S 0 6942 1 0 80 0 - 3560 poll ? 00:00:00 gdm
5 S 0 6943 6942 0 80 0 - 3685 select ? 00:00:00 gdm
4 R 0 6948 6943 5 80 0 - 17706 - tty7 00:00:46 Xorg
1 S 0 6965 1 0 80 0 - 1084 poll ? 00:00:00 system-tools-b
1 S 1 6983 1 0 80 0 - 517 hrtime ? 00:00:00 atd
1 S 0 7015 1 0 80 0 - 853 hrtime ? 00:00:00 cron
4 S 0 7106 1 0 80 0 - 739 wait tty1 00:00:00 login
4 S 999 7115 7106 0 80 0 - 1440 read_c tty1 00:00:00 bash
4 S 999 7223 6943 0 80 0 - 6191 poll ? 00:00:00 x-session-mana
1 S 999 7418 7223 0 80 0 - 1185 select ? 00:00:00 ssh-agent
1 S 999 7421 1 0 80 0 - 781 select ? 00:00:00 dbus-launch
1 S 999 7422 1 0 80 0 - 759 poll ? 00:00:00 dbus-daemon
1 S 999 7425 1 0 69 -11 - 7227 poll ? 00:00:00 pulseaudio
0 S 999 7428 7425 0 80 0 - 1882 poll ? 00:00:00 gconf-helper
0 S 999 7430 1 0 80 0 - 1932 poll ? 00:00:01 gconfd-2
1 S 999 7440 7223 0 80 0 - 4428 poll ? 00:00:00 seahorse-agent
0 S 999 7444 7223 0 80 0 - 3479 poll ? 00:00:00 gnome-keyring-
1 S 999 7447 1 0 80 0 - 3707 poll ? 00:00:00 gnome-keyring-
1 S 999 7449 1 0 80 0 - 10275 poll ? 00:00:01 gnome-settings
0 S 999 7450 7223 0 80 0 - 461 wait ? 00:00:00 compiz
0 S 999 7513 1 0 80 0 - 1422 poll ? 00:00:00 gvfsd
0 S 999 7516 7450 0 80 0 - 5476 poll ? 00:00:07 compiz.real
1 S 999 7522 1 0 80 0 - 7299 futex_ ? 00:00:00 gvfs-fuse-daem
0 S 999 7535 7223 1 80 0 - 9651 poll ? 00:00:11 gnome-panel
0 S 999 7536 7223 1 80 0 - 16616 poll ? 00:00:10 nautilus
0 S 999 7539 1 0 80 0 - 8130 poll ? 00:00:00 bonobo-activat
0 S 999 7554 7223 0 80 0 - 9887 poll ? 00:00:00 evolution-alar
0 S 999 7555 7223 0 80 0 - 3687 poll ? 00:00:00 bluetooth-appl
0 S 999 7559 7223 0 80 0 - 10099 poll ? 00:00:05 nm-applet
0 S 999 7565 7223 0 80 0 - 6369 poll ? 00:00:01 python
0 S 999 7566 7223 0 80 0 - 6596 poll ? 00:00:00 update-notifie
0 S 999 7573 1 0 80 0 - 3535 poll ? 00:00:00 gvfs-hal-volum
1 S 999 7574 1 0 80 0 - 5921 poll ? 00:00:00 gnome-power-ma
0 S 999 7577 1 0 80 0 - 1392 poll ? 00:00:00 gvfs-gphoto2-v
0 S 999 7580 1 0 80 0 - 1389 poll ? 00:00:00 gvfsd-burn
0 S 999 7589 7516 0 80 0 - 461 wait ? 00:00:00 sh
0 S 999 7590 7589 0 80 0 - 461 wait ? 00:00:00 compiz-decorat
0 S 999 7592 7590 0 80 0 - 5343 poll ? 00:00:04 gtk-window-dec
0 S 999 7599 1 0 80 0 - 5792 poll ? 00:00:00 trashapplet
0 S 999 7607 1 0 80 0 - 5548 poll ? 00:00:00 gvfsd-trash
1 S 999 7638 1 0 80 0 - 5304 poll ? 00:00:02 gnome-screensa
0 S 999 7665 1 0 80 0 - 6728 poll ? 00:00:00 fast-user-swit
0 S 999 7668 1 0 80 0 - 11267 poll ? 00:00:00 mixer_applet2
0 S 999 7817 1 0 80 0 - 6018 poll ? 00:00:00 notification-d
0 S 999 7823 1 0 99 19 - 7729 poll ? 00:00:00 trackerd
4 S 0 7885 6842 0 80 0 - 563 select ? 00:00:00 dhclient
0 S 999 8017 1 0 80 0 - 8097 poll ? 00:00:00 evolution-exch
1 S 0 8051 2 0 75 -5 - 0 scsi_e ? 00:00:00 scsi_eh_2
1 S 0 8052 2 0 75 -5 - 0 usb_st ? 00:00:00 usb-storage
0 S 0 8107 6696 0 80 0 - 860 poll ? 00:00:00 hald-addon-sto
0 S 999 8145 1 0 80 0 - 1611 poll ? 00:00:00 gvfsd-network
0 S 999 8151 1 0 80 0 - 5461 poll ? 00:00:00 gvfsd-smb-brow
0 S 999 8154 1 0 80 0 - 1421 poll ? 00:00:00 gvfsd-dnssd
0 S 999 8260 1 4 80 0 - 51231 poll ? 00:00:20 soffice.bin
0 S 999 8310 1 7 80 0 - 36918 poll ? 00:00:25 firefox
0 S 999 8474 1 1 80 0 - 26454 select ? 00:00:04 gnome-terminal
0 S 999 8489 8474 0 80 0 - 728 unix_s ? 00:00:00 gnome-pty-help
0 S 999 8490 8474 0 80 0 - 1436 wait pts/0 00:00:00 bash
0 R 999 8646 8490 0 80 0 - 629 - pts/0 00:00:00 ps
1 answer
You need to sort by the PPID parent process ID first, so that you can trace each process back through its parents. Everything traces back to 0 eventually.
Example: Process 6017's parent is 6003. 6003's parent is 1. 1's parent is 0.
The details of how you do that - a spreadsheet or databse or graphing program - will be up to you, but the end result is you writing a tree that starts with PID 0, which branches to PIDs 1 and 2, then PID 1 branches to 4075, 6003, etc, while PID 2 branches to 3, 4, 5, 6, etc.
I just got those rough results by pasting your table into a spreadsheet, and sorting by PPID, then PID, but you'll need to do more shaping than that to make it into a tree.