ps: possibility to display systemd unit for a process

Library systemd-login offers possibility to display
name of a systemd unit file for specific pid. Note that
not all processes are part of a system unit/service
(e.g. user processes, or kernel threads).

This patch adds output option "sd_unit" which will
show name of systemd unit or "-", when process does not
belong to any unit.

To maintain compatibility with non-systemd systems,
procps must be configured with --with-systemd option
to enable this option.
This commit is contained in:
Lukas Nykryn
2013-04-16 14:42:30 +02:00
parent 53fd7dd1ed
commit 7ab5d33c5c
4 changed files with 51 additions and 0 deletions

View File

@@ -264,6 +264,24 @@ then
fi
AC_SUBST(DEJAGNU)
AC_ARG_WITH([systemd],
[AS_HELP_STRING([--with-systemd], [enable systemd support])],
[], [with_systemd=no])
if test "x$with_systemd" != xno; then
PKG_CHECK_MODULES([SYSTEMD], [libsystemd-login], [], [
AC_CHECK_LIB(systemd-login, sd_pid_get_unit, [have_systemd=yes], [have_systemd=no])
if test "x$have_systemd" = xno; then
AC_MSG_ERROR([systemd support missing/incomplete])
fi
SYSTEMD_LIBS="-lsystemd-login"
])
AM_CONDITIONAL(WITH_SYSTEMD, true)
AC_DEFINE(WITH_SYSTEMD, 1, [enable systemd support])
else
AM_CONDITIONAL(WITH_SYSTEMD, false)
fi
AC_CONFIG_FILES([
Makefile
include/Makefile