summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-12-21 04:54:46 +0000
committerMiles Bader <miles@gnu.org>1995-12-21 04:54:46 +0000
commit944cb1dc4aba813de2e3d2c5f8b4c4fc60bcc5e4 (patch)
treefb41b990f01506d136bf5da21e69ed9413b7b973
parenta5acf49db7eafb084f3483f3e9c44233e08ab466 (diff)
(ps_not_leader_p): Renamed from ps_not_sess_leader_p.
(ps_not_leader_filter): Renamed from ps_not_sess_leader_filter. (ps_unorphaned_p): Include login leaders as well as session leaders. (ps_own_filter): Depend on PSTAT_OWNER_UID. (ps_own_p): Account for there being no uid.
-rw-r--r--libps/filters.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/libps/filters.c b/libps/filters.c
index 0efc7436..f31246a7 100644
--- a/libps/filters.c
+++ b/libps/filters.c
@@ -31,29 +31,32 @@
/* ---------------------------------------------------------------- */
static bool
-ps_own_p(proc_stat_t ps)
+ps_own_p (proc_stat_t ps)
{
- static int own_uid = -1;
- if (own_uid < 0)
- own_uid = getuid();
- return own_uid == proc_stat_proc_info(ps)->owner;
+ static int own_uid = -2; /* -1 means no uid at all. */
+ if (own_uid == -2)
+ own_uid = getuid ();
+ return own_uid >= 0 && own_uid == proc_stat_owner_uid (ps);
}
struct ps_filter ps_own_filter =
-{"own", PSTAT_PROC_INFO, ps_own_p};
+{"own", PSTAT_OWNER_UID, ps_own_p};
static bool
-ps_not_sess_leader_p(proc_stat_t ps)
+ps_not_leader_p (proc_stat_t ps)
{
- return !(proc_stat_state(ps) & PSTAT_STATE_P_SESSLDR);
+ return
+ !(proc_stat_state(ps) & (PSTAT_STATE_P_SESSLDR | PSTAT_STATE_P_LOGINLDR));
}
-struct ps_filter ps_not_sess_leader_filter =
-{"not-sess-leader", PSTAT_STATE, ps_not_sess_leader_p};
+struct ps_filter ps_not_leader_filter =
+{"not-sess-leader", PSTAT_STATE, ps_not_leader_p};
static bool
ps_unorphaned_p(proc_stat_t ps)
{
int state = proc_stat_state(ps);
- return !(state & PSTAT_STATE_P_ORPHAN) || (state & PSTAT_STATE_P_SESSLDR);
+ return
+ !(state & PSTAT_STATE_P_ORPHAN)
+ || (state & (PSTAT_STATE_P_SESSLDR | PSTAT_STATE_P_LOGINLDR));
}
struct ps_filter ps_unorphaned_filter =
{"unorphaned", PSTAT_STATE, ps_unorphaned_p};