From 5db0c7e10ac53ae2a00e67cd345c2bcd6583ed1d Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Wed, 18 Oct 2006 13:24:19 +0000 Subject: [PATCH] (desirable_utmp_entry): Implement new flag: READ_UTMP_USER_PROCESS. --- lib/readutmp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/readutmp.c b/lib/readutmp.c index cf29572f0..aec1fee44 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -69,10 +69,15 @@ extract_trimmed_name (const STRUCT_UTMP *ut) static inline bool desirable_utmp_entry (STRUCT_UTMP const *u, int options) { - return ! (options & READ_UTMP_CHECK_PIDS - && IS_USER_PROCESS (u) - && (UT_PID (u) <= 0 - || (kill (UT_PID (u), 0) < 0 && errno == ESRCH))); + int up = IS_USER_PROCESS (u); + if ((options & READ_UTMP_USER_PROCESS) && !up) + return false; + if ((options & READ_UTMP_CHECK_PIDS) + && up + && (UT_PID (u) <= 0 + || (kill (UT_PID (u), 0) < 0 && errno == ESRCH))) + return false; + return true; } /* Read the utmp entries corresponding to file FILE into freshly- -- 2.11.0