summaryrefslogtreecommitdiff
path: root/libps
diff options
context:
space:
mode:
Diffstat (limited to 'libps')
-rw-r--r--libps/procstat.c4
-rw-r--r--libps/ps.h4
-rw-r--r--libps/spec.c10
3 files changed, 18 insertions, 0 deletions
diff --git a/libps/procstat.c b/libps/procstat.c
index 6e920f4f..eac4ae42 100644
--- a/libps/procstat.c
+++ b/libps/procstat.c
@@ -990,6 +990,10 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags)
if (ps_context_find_tty_by_cttyid (ps->context, ps->cttyid, &ps->tty) == 0)
have |= PSTAT_TTY;
+ /* The number of Mach ports in the task. */
+ MGET (PSTAT_NUM_PORTS, PSTAT_PID,
+ proc_getnports (server, ps->pid, &ps->num_ports));
+
/* Update PS's flag state. We haven't tried user flags yet, so don't mark
them as having failed. We do this before checking user bits so that the
user fetch hook sees PS in a consistent state. */
diff --git a/libps/ps.h b/libps/ps.h
index a013c44e..b85ede46 100644
--- a/libps/ps.h
+++ b/libps/ps.h
@@ -303,6 +303,8 @@ struct proc_stat
char *env;
/* The length of ENV. */
size_t env_len;
+
+ unsigned num_ports;
};
/* Proc_stat flag bits; each bit is set in the FLAGS field if that
@@ -340,6 +342,7 @@ struct proc_stat
#define PSTAT_OWNER_UID 0x200000 /* The uid of the the proc's owner */
#define PSTAT_UMASK 0x400000 /* The proc's current umask */
#define PSTAT_HOOK 0x800000 /* Has a non-zero hook */
+#define PSTAT_NUM_PORTS 0x4000000 /* Number of Mach ports in the task */
/* Flag bits that don't correspond precisely to any field. */
#define PSTAT_NO_MSGPORT 0x1000000 /* Don't use the msgport at all */
@@ -443,6 +446,7 @@ extern char *proc_stat_state_tags;
#define proc_stat_umask(ps) ((ps)->umask)
#define proc_stat_tty(ps) ((ps)->tty)
#define proc_stat_task_events_info(ps) ((ps)->task_events_info)
+#define proc_stat_num_ports(ps) ((ps)->num_ports)
#define proc_stat_has(ps, needs) (((ps)->flags & needs) == needs)
/* True if PS refers to a thread and not a process. */
diff --git a/libps/spec.c b/libps/spec.c
index da1e372a..5499bc15 100644
--- a/libps/spec.c
+++ b/libps/spec.c
@@ -349,6 +349,14 @@ ps_get_zero_fills (struct proc_stat *ps)
const struct ps_getter ps_zero_fills_getter =
{"zero_fills", PSTAT_TASK_EVENTS, (vf) ps_get_zero_fills};
+static int
+ps_get_num_ports (struct proc_stat *ps)
+{
+ return proc_stat_num_ports (ps);
+}
+const struct ps_getter ps_num_ports_getter =
+{"num_ports", PSTAT_NUM_PORTS, (vf) ps_get_num_ports};
+
/* ---------------------------------------------------------------- */
/* some printing functions */
@@ -1155,6 +1163,8 @@ static const struct ps_fmt_spec specs[] =
&ps_msgs_sent_getter, ps_emit_int, ps_cmp_ints, ps_nominal_zint},
{"ZFills", 0, -5, -1, 0,
&ps_zero_fills_getter, ps_emit_int, ps_cmp_ints, ps_nominal_zint},
+ {"Ports", 0, -5, -1, 0,
+ &ps_num_ports_getter, ps_emit_int, ps_cmp_ints, 0},
{0}
};