bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read_utmp changes


From: Sergey Poznyakoff
Subject: read_utmp changes
Date: Wed, 18 Oct 2006 16:28:19 +0300

I have installed the following change to read_utmp:

2006-10-18  Sergey Poznyakoff  <address@hidden>

        * lib/readutmp.c (desirable_utmp_entry): Implement new flag:
        READ_UTMP_USER_PROCESS.
        * lib/readutmp.h (READ_UTMP_USER_PROCESS): New flag

Index: lib/readutmp.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/readutmp.c,v
retrieving revision 1.25
diff -p -u -r1.25 readutmp.c
--- lib/readutmp.c      13 Sep 2006 22:38:14 -0000      1.25
+++ lib/readutmp.c      18 Oct 2006 13:23:43 -0000
@@ -69,10 +69,15 @@ extract_trimmed_name (const STRUCT_UTMP 
 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-
Index: lib/readutmp.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/readutmp.h,v
retrieving revision 1.21
diff -p -u -r1.21 readutmp.h
--- lib/readutmp.h      22 Aug 2006 17:34:55 -0000      1.21
+++ lib/readutmp.h      18 Oct 2006 13:23:43 -0000
@@ -202,7 +202,8 @@ enum { UT_USER_SIZE = sizeof UT_USER ((S
 /* Options for read_utmp.  */
 enum
   {
-    READ_UTMP_CHECK_PIDS = 1
+    READ_UTMP_CHECK_PIDS = 1,
+    READ_UTMP_USER_PROCESS = 2
   };
 
 char *extract_trimmed_name (const STRUCT_UTMP *ut);
        
                




reply via email to

[Prev in Thread] Current Thread [Next in Thread]