diff options
author | Andrea Monaco <andrea.monaco@autistici.org> | 2021-12-08 17:51:08 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-12-08 17:51:12 +0100 |
commit | 867b8079569662ce2a22f2885ac8cdf168def822 (patch) | |
tree | 3e478695953472a5dd71505d553cd885d62059d0 /libps | |
parent | 04983c57ab0fbde06eadd22e6c038a0e7c959fc3 (diff) | |
download | hurd-867b8079569662ce2a22f2885ac8cdf168def822.tar.gz hurd-867b8079569662ce2a22f2885ac8cdf168def822.tar.bz2 hurd-867b8079569662ce2a22f2885ac8cdf168def822.zip |
Add "comm" as a format spec to ps
comm was not recognized by Hurd's ps as a format spec, but is required by
POSIX to display the command name (like "exe", but without the full path).
Diffstat (limited to 'libps')
-rw-r--r-- | libps/spec.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libps/spec.c b/libps/spec.c index c9164f9d..adca2e9c 100644 --- a/libps/spec.c +++ b/libps/spec.c @@ -372,6 +372,17 @@ ps_get_exe (struct proc_stat *ps, char **exe_p, int *exe_len_p) } const struct ps_getter ps_exe_getter = {"exe", PSTAT_EXE, ps_get_exe}; + +static void +ps_get_comm (struct proc_stat *ps, char **comm_p, int *comm_len_p) +{ + /* The GNU basename doesn't alter the string passed as arg */ + *comm_p = basename (proc_stat_exe (ps)); + *comm_len_p = strlen (*comm_p); +} +const struct ps_getter ps_comm_getter = +{"comm", PSTAT_EXE, ps_get_comm}; + /* ---------------------------------------------------------------- */ /* some printing functions */ @@ -1128,6 +1139,8 @@ static const struct ps_fmt_spec specs[] = &ps_args_getter, ps_emit_args, ps_cmp_strings,ps_nominal_string}, {"Arg0", 0, 0, -1, 0, &ps_args_getter, ps_emit_string, ps_cmp_strings,ps_nominal_string}, + {"Comm", "COMMAND", 0, -1, 0, + &ps_comm_getter, ps_emit_string, ps_cmp_strings,ps_nominal_string}, {"Env", 0, 0, -1, 0, &ps_env_getter, ps_emit_args, ps_cmp_strings,ps_nominal_string}, {"Start", 0, -7, 1, 0, |