ps: possibility to display slice unit for a process
Library systemd-login offers possibility to display name of a systemd slice unit for specific pid. This patch adds output option "slice" which will show name of systemd slice 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:
parent
f5d15f4718
commit
d66ed3350e
@ -154,8 +154,8 @@ AC_ARG_WITH([systemd],
|
|||||||
[], [with_systemd=no]
|
[], [with_systemd=no]
|
||||||
)
|
)
|
||||||
if test "x$with_systemd" != xno; then
|
if test "x$with_systemd" != xno; then
|
||||||
PKG_CHECK_MODULES([SYSTEMD], [libsystemd-login >= 202], [], [
|
PKG_CHECK_MODULES([SYSTEMD], [libsystemd-login >= 206], [], [
|
||||||
AC_CHECK_LIB(systemd-login, sd_pid_get_machine_name, [have_systemd=yes], [have_systemd=no])
|
AC_CHECK_LIB(systemd-login, sd_pid_get_slice, [have_systemd=yes], [have_systemd=no])
|
||||||
if test "x$have_systemd" = xno; then
|
if test "x$have_systemd" = xno; then
|
||||||
AC_MSG_ERROR([systemd support missing/incomplete])
|
AC_MSG_ERROR([systemd support missing/incomplete])
|
||||||
fi
|
fi
|
||||||
|
20
ps/output.c
20
ps/output.c
@ -1292,6 +1292,23 @@ fail:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int pr_sd_slice(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
|
int r;
|
||||||
|
size_t len;
|
||||||
|
char *slice;
|
||||||
|
|
||||||
|
r = sd_pid_get_slice(pp->tgid, &slice);
|
||||||
|
if(r<0) goto fail;
|
||||||
|
len = snprintf(outbuf, COLWID, "%s", slice);
|
||||||
|
free(slice);
|
||||||
|
return len;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
outbuf[0] = '-';
|
||||||
|
outbuf[1] = '\0';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/************************ Linux namespaces ******************************/
|
/************************ Linux namespaces ******************************/
|
||||||
|
|
||||||
@ -1675,6 +1692,9 @@ static const format_struct format_array[] = {
|
|||||||
{"sigmask", "BLOCKED", pr_sigmask, sr_nop, 9, 0, XXX, TO|SIGNAL}, /*blocked*/
|
{"sigmask", "BLOCKED", pr_sigmask, sr_nop, 9, 0, XXX, TO|SIGNAL}, /*blocked*/
|
||||||
{"size", "SIZE", pr_swapable, sr_swapable, 5, 0, SCO, PO|RIGHT},
|
{"size", "SIZE", pr_swapable, sr_swapable, 5, 0, SCO, PO|RIGHT},
|
||||||
{"sl", "SL", pr_nop, sr_nop, 3, 0, XXX, AN|RIGHT},
|
{"sl", "SL", pr_nop, sr_nop, 3, 0, XXX, AN|RIGHT},
|
||||||
|
#ifdef WITH_SYSTEMD
|
||||||
|
{"slice", "SLICE", pr_sd_slice, sr_nop, 31, 0, LNX, ET|LEFT},
|
||||||
|
#endif
|
||||||
{"spid", "SPID", pr_tasks, sr_tasks, 5, 0, SGI, TO|PIDMAX|RIGHT},
|
{"spid", "SPID", pr_tasks, sr_tasks, 5, 0, SGI, TO|PIDMAX|RIGHT},
|
||||||
{"stackp", "STACKP", pr_stackp, sr_start_stack, 8, 0, LNX, PO|RIGHT}, /*start_stack*/
|
{"stackp", "STACKP", pr_stackp, sr_start_stack, 8, 0, LNX, PO|RIGHT}, /*start_stack*/
|
||||||
{"start", "STARTED", pr_start, sr_nop, 8, 0, XXX, ET|RIGHT},
|
{"start", "STARTED", pr_start, sr_nop, 8, 0, XXX, ET|RIGHT},
|
||||||
|
Loading…
Reference in New Issue
Block a user