A) Is there a way to determine the systemd unit that caused the creation of a specific process (in my example output, process 2738, the PA daemon)?
Claro. Você pode executar systemctl status <pid>
e o systemd encontrará a unidade que contém esse PID. Por exemplo, no meu sistema eu encontro um processo dnsmasq
:
# ps -fe | grep dnsmasq
nobody 18834 1193 0 Aug25 ? 00:00:10 /usr/sbin/dnsmasq ...
Quem começou?
# systemctl status 18834
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2015-08-25 11:07:40 EDT; 1 day 21h ago
Main PID: 1193 (NetworkManager)
Memory: 1.1M
CGroup: /system.slice/NetworkManager.service
├─ 1193 /usr/sbin/NetworkManager --no-daemon
├─ 1337 /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-wlp3s0....
├─18682 /usr/libexec/nm-openvpn-service
├─18792 /usr/sbin/openvpn --remote ovpn-phx2.redhat.com 443 tcp --nobind --dev redhat --de...
└─18834 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --...
Eu também tenho um processo pulseaudio
:
# ps -fe | grep pulseaudio
lars 2948 1 0 Aug25 ? 00:06:20 /usr/bin/pulseaudio --start
Executando systemctl status 2948
, vejo:
● session-3.scope - Session 3 of user lars
Loaded: loaded (/run/systemd/system/session-3.scope; static; vendor preset: disabled)
Drop-In: /run/systemd/system/session-3.scope.d
└─50-After-systemd-logind\x2eservice.conf, 50-After-systemd-user-sessions\x2eservice.conf, 50-Description.conf, 50-SendSIGHUP.conf, 50-Slice.conf
Active: active (running) since Tue 2015-08-25 11:09:23 EDT; 1 day 21h ago
CGroup: /user.slice/user-1000.slice/session-3.scope
Isso me diz que o pulseaudio
foi iniciado a partir da minha sessão de login no desktop, em vez de explicitamente via systemd.