From d4849e6ebdae76511eb370724f2a90be54e00d5c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 27 Dec 2011 17:31:20 +0100 Subject: Do not use msgport information * process.c (process_lookup_pid): Set PSTAT_NO_MSGPORT flag. * rootdir.c (get_boottime, get_idletime, rootdir_gc_cmdline): Set PSTAT_NO_MSGPORT flag. --- process.c | 2 ++ rootdir.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/process.c b/process.c index 6652a4e9..e812a1f1 100644 --- a/process.c +++ b/process.c @@ -362,6 +362,8 @@ process_lookup_pid (struct ps_context *pc, pid_t pid, struct node **np) if (err) return EIO; + proc_stat_set_flags (ps, PSTAT_NO_MSGPORT); + err = proc_stat_set_flags (ps, PSTAT_OWNER_UID); if (err || ! (proc_stat_flags (ps) & PSTAT_OWNER_UID)) { diff --git a/rootdir.c b/rootdir.c index 1fa71b03..018de617 100644 --- a/rootdir.c +++ b/rootdir.c @@ -52,6 +52,8 @@ get_boottime (struct ps_context *pc, struct timeval *tv) if (err) return err; + proc_stat_set_flags (ps, PSTAT_NO_MSGPORT); + err = proc_stat_set_flags (ps, PSTAT_TASK_BASIC); if (err || !(proc_stat_flags (ps) & PSTAT_TASK_BASIC)) err = EIO; @@ -82,6 +84,8 @@ get_idletime (struct ps_context *pc, struct timeval *tv) pst = NULL, tbi = NULL; + proc_stat_set_flags (ps, PSTAT_NO_MSGPORT); + err = proc_stat_set_flags (ps, PSTAT_NUM_THREADS); if (err || !(proc_stat_flags (ps) & PSTAT_NUM_THREADS)) { @@ -360,6 +364,8 @@ rootdir_gc_cmdline (void *hook, char **contents, ssize_t *contents_len) if (err) return EIO; + proc_stat_set_flags (ps, PSTAT_NO_MSGPORT); + err = proc_stat_set_flags (ps, PSTAT_ARGS); if (err || ! (proc_stat_flags (ps) & PSTAT_ARGS)) { -- cgit v1.2.3 From a9278fb8b6c1d7e160b6f79f7f28f92f940d4918 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 27 Dec 2011 18:13:00 +0100 Subject: Revert "Do not use msgport information" This reverts commit d9fc76bd4e8c9a459fad7152135b738496318415, as it breaks /proc/pid/stat --- process.c | 2 -- rootdir.c | 6 ------ 2 files changed, 8 deletions(-) diff --git a/process.c b/process.c index e812a1f1..6652a4e9 100644 --- a/process.c +++ b/process.c @@ -362,8 +362,6 @@ process_lookup_pid (struct ps_context *pc, pid_t pid, struct node **np) if (err) return EIO; - proc_stat_set_flags (ps, PSTAT_NO_MSGPORT); - err = proc_stat_set_flags (ps, PSTAT_OWNER_UID); if (err || ! (proc_stat_flags (ps) & PSTAT_OWNER_UID)) { diff --git a/rootdir.c b/rootdir.c index 018de617..1fa71b03 100644 --- a/rootdir.c +++ b/rootdir.c @@ -52,8 +52,6 @@ get_boottime (struct ps_context *pc, struct timeval *tv) if (err) return err; - proc_stat_set_flags (ps, PSTAT_NO_MSGPORT); - err = proc_stat_set_flags (ps, PSTAT_TASK_BASIC); if (err || !(proc_stat_flags (ps) & PSTAT_TASK_BASIC)) err = EIO; @@ -84,8 +82,6 @@ get_idletime (struct ps_context *pc, struct timeval *tv) pst = NULL, tbi = NULL; - proc_stat_set_flags (ps, PSTAT_NO_MSGPORT); - err = proc_stat_set_flags (ps, PSTAT_NUM_THREADS); if (err || !(proc_stat_flags (ps) & PSTAT_NUM_THREADS)) { @@ -364,8 +360,6 @@ rootdir_gc_cmdline (void *hook, char **contents, ssize_t *contents_len) if (err) return EIO; - proc_stat_set_flags (ps, PSTAT_NO_MSGPORT); - err = proc_stat_set_flags (ps, PSTAT_ARGS); if (err || ! (proc_stat_flags (ps) & PSTAT_ARGS)) { -- cgit v1.2.3 From cc2cff23dedcff0fd9fa94386e42a4d824bd0c7d Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sat, 14 Jan 2012 14:47:58 +0100 Subject: PID stat/status: show only the file name of processes The Linux /proc fs shows only the file name of processes in the `stat' and `status' files of every process directory, so adapt also procfs to show process file names. Add a new `args_filename` function, much similar to GNU's `basename' but returning the original string also when the resulting file name is an empty string. * process.c (args_filename): New function. (process_file_gc_stat): Wrap the `proc_stat_args' result with `args_filename'. (process_file_gc_status): Likewise. --- process.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/process.c b/process.c index 6652a4e9..17a38ea8 100644 --- a/process.c +++ b/process.c @@ -81,6 +81,12 @@ static long long int timeval_jiffies (time_value_t tv) return secs * opt_clk_tck / 1000000.; } +static const char *args_filename (const char *name) +{ + char *sp = strrchr (name, '/'); + return sp != NULL && *(sp + 1) != '\0' ? sp + 1 : name; +} + /* Actual content generators */ static ssize_t @@ -126,7 +132,7 @@ process_file_gc_stat (struct proc_stat *ps, char **contents) "%u %u " /* RT priority and policy */ "%llu " /* aggregated block I/O delay */ "\n", - proc_stat_pid (ps), proc_stat_args (ps), state_char (ps), + proc_stat_pid (ps), args_filename (proc_stat_args (ps)), state_char (ps), pi->ppid, pi->pgrp, pi->session, 0, 0, /* no such thing as a major:minor for ctty */ 0, /* no such thing as CLONE_* flags on Hurd */ @@ -178,7 +184,7 @@ process_file_gc_status (struct proc_stat *ps, char **contents) "VmRSS:\t%8u kB\n" "VmHWM:\t%8u kB\n" /* ie. resident peak */ "Threads:\t%u\n", - proc_stat_args (ps), + args_filename (proc_stat_args (ps)), state_string (ps), proc_stat_pid (ps), /* XXX will need more work for threads */ proc_stat_pid (ps), -- cgit v1.2.3