pstree – display a tree of processes


ABOUT pstree

pstree shows running processes as a tree.  The tree is rooted at either pid  or  init  if  pid  is
omitted.   If a user name is specified, all process trees rooted at processes owned by that user are
shown.

[bash]
$pstree -A
init-+-NetworkManager—3*[{NetworkManager}]
|-accounts-daemon—2*[{accounts-daemon}]
|-acpid
|-at-spi-bus-laun-+-dbus-daemon
| `-3*[{at-spi-bus-laun}]
|-at-spi2-registr—{at-spi2-registr}
|-atd
|-avahi-daemon—avahi-daemon
|-bluetoothd
|-colord—2*[{colord}]
|-console-kit-dae—64*[{console-kit-dae}]
|-cron
|-2*[dbus-daemon]
|-dbus-launch
|-dconf-service—2*[{dconf-service}]
|-dhclient
|-evolution-addre—4*[{evolution-addre}]
|-evolution-calen—4*[{evolution-calen}]
|-evolution-sourc—2*[{evolution-sourc}]
|-exim4
|-gconfd-2
|-gdm3-+-gdm-simple-slav-+-Xorg—{Xorg}
| | |-gdm-session-wor-+-gnome-session-+-applet.py—{applet.py}
| | | | |-evolution-alarm—4*[{evolution-alarm}]
| | | | |-gnome-settings—-3*[{gnome-settings-}]
| | | | |-gnome-shell-+-chrome-+-chrome
| | | | | | |-chrome-sandbox—chro+
| | | | | | `-39*[{chrome}]
| | | | | `-6*[{gnome-shell}]
| | | | |-ssh-agent
| | | | |-tracker-store—7*[{tracker-store}]
| | | | `-3*[{gnome-session}]
| | | `-2*[{gdm-session-wor}]
| | `-2*[{gdm-simple-slav}]
| `-2*[{gdm3}]
|-6*
|-gnome-keyring-d—7*[{gnome-keyring-d}]
|-gnome-shell-cal—4*[{gnome-shell-cal}]
|-gnome-terminal–+-bash—emacs
| |-bash—pstree
| |-gnome-pty-helpe
| `-3*[{gnome-terminal-}]
|-goa-daemon—3*[{goa-daemon}]
|-gpm
|-gsd-printer—{gsd-printer}
|-gvfs-afc-volume—2*[{gvfs-afc-volume}]
|-gvfs-goa-volume—{gvfs-goa-volume}
|-gvfs-gphoto2-vo—{gvfs-gphoto2-vo}
|-gvfs-mtp-volume—{gvfs-mtp-volume}
|-gvfs-udisks2-vo—2*[{gvfs-udisks2-vo}]
|-gvfsd—{gvfsd}
|-gvfsd-burn—2*[{gvfsd-burn}]
|-mission-control—2*[{mission-control}]
|-modem-manager
|-ntpd
|-polkitd—2*[{polkitd}]
|-pulseaudio—2*[{pulseaudio}]
|-rsyslogd—3*[{rsyslogd}]
|-rtkit-daemon—2*[{rtkit-daemon}]
|-sshd
|-systemd-logind
|-udevd
|-udisksd—4*[{udisksd}]
|-upowerd—2*[{upowerd}]
`-wpa_supplicant
$
[/bash]

UNIX Explanation

pstree  shows running processes  as a  tree. The  tree is rooted at either pid or init if pid is omitted.
If a user name is specified, all  process trees rooted at processes owned by that user are shown.

RELATED SOURCE CODE EXPOSITION
[c]
static void free_buffers()
{
if (width != NULL) {
free(width);
width = NULL;
}
if (more != NULL) {
free(more);
more = NULL;
}
capacity = 0;
}
[/c]

SOURCE CODE HIGHLIGHT

Frees any buffers allocated by ensure_buffer_capacity.

RELATED KNOWLEDGE

The   fundamental  data   structure  within   the  kernel controlling all processes is the process
structure, which grows and shrinks dynamically as processes are forked and finished or killed.

LINKS
https://www.howtoforge.com/linux-pstree-command/
http://man7.org/linux/man-pages/man1/pstree.1.html


%d bloggers like this: