A toy to show how to implement a simple pstree
in Rust. It prints out all the processes and its children processes.
$ cargo run
+-1 (systemd)
+-429 (systemd-journal)
+-466 (multipathd)
+-478 (systemd-udevd)
+-707 (systemd-oomd)
+-708 (systemd-timesyn)
+-823 (systemd-network)
+-825 (systemd-resolve)
+-836 (acpid)
+-838 (avahi-daemon)
| +-890 (avahi-daemon)
+-839 (dbus-daemon)
+-840 (NetworkManager)
+-847 (irqbalance)
+-852 (networkd-dispat)
+-857 (polkitd)
+-860 (power-profiles-)
+-862 (rsyslogd)
+-865 (snapd)
+-870 (accounts-daemon)
+-871 (switcheroo-cont)
+-872 (systemd-logind)
+-878 (udisksd)
+-881 (wpa_supplicant)
+-921 (ModemManager)
+-929 (cloudflared)
+-944 (containerd)
+-967 (unattended-upgr)
+-1005 (cron)
+-1018 (agetty)
+-1028 (kerneloops)
+-1033 (kerneloops)
+-1051 (gdm3)
| +-1062 (gdm-session-wor)
| | +-1115 (gdm-wayland-ses)
| | | +-1122 (dbus-run-sessio)
| | | | +-1124 (dbus-daemon)
| | | | +-1125 (gnome-session-b)
| | | | | +-1156 (gnome-shell)
| | | | | | +-1343 (Xwayland)
| | | | | | +-1970 (ibus-daemon)
| | | | | | | +-1989 (ibus-dconf)
| | | | | | | +-2068 (ibus-engine-sim)
| | | | | +-1683 (gsd-sharing)
| | | | | +-1685 (gsd-wacom)
| | | | | +-1688 (gsd-color)
| | | | | +-1695 (gsd-keyboard)
| | | | | +-1706 (gsd-print-notif)
| | | | | +-1710 (gsd-rfkill)
| | | | | +-1717 (gsd-smartcard)
| | | | | +-1720 (gsd-datetime)
| | | | | +-1725 (gsd-media-keys)
| | | | | +-1730 (gsd-screensaver)
| | | | | +-1746 (gsd-sound)
| | | | | +-1747 (gsd-a11y-settin)
| | | | | +-1753 (gsd-housekeepin)
| | | | | +-1759 (gsd-power)
+-1069 (dockerd)
...