A função da API libsystemd é sd_pid_get_unit(…)
. Na linha de comando, você pode usar ps
com a coluna UNIT (se ela foi compilada com o suporte libsystemd):
$ ps -e -o pid,unit,cmd PID UNIT CMD 1 init.scope /usr/lib/systemd/systemd 315 postfix.service tlsmgr -l -t unix -u 3057 cronie.service /usr/bin/CROND -n 3107 galed.service /usr/bin/galed 3182 [email protected] /sbin/agetty --noclear tty1 linux 29171 postfix.service /usr/lib/postfix/bin/master -w 32758 postfix.service qmgr -l -t unix -u $ ps -o unit= 32758 postfix.service $ ps -o unit= -C tlsmgr postfix.service $ systemctl status $(pidof pickup) ● postfix.service - Postfix Mail Transport Agent Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2016-03-27 17:24:24 EEST; 2 weeks 2 days ago Main PID: 29171 (master) Tasks: 4 (limit: 512) CGroup: /system.slice/postfix.service ├─ 315 tlsmgr -l -t unix -u ├─ 8720 pickup -l -t unix -u ├─29171 /usr/lib/postfix/bin/master -w └─32758 qmgr -l -t unix -u $ grep :name=systemd: /proc/$(pidof pickup)/cgroup 1:name=systemd:/system.slice/postfix.service # do not rely on this one, as the cgroup structure will change in the coming months