[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] who and stale utmp entries
From: |
Tim Waugh |
Subject: |
[patch] who and stale utmp entries |
Date: |
Wed, 23 Mar 2005 14:10:31 +0000 |
User-agent: |
Mutt/1.4.2.1i |
Hi,
Here is a patch to prevent the who(1) command showing stale utmp
entries of user logins.
Tim.
*/
--- coreutils-5.2.1/src/who.c.stale-utmp 2005-03-23 13:43:55.000000000
+0000
+++ coreutils-5.2.1/src/who.c 2005-03-23 13:46:44.000000000 +0000
@@ -27,6 +27,8 @@
#include <config.h>
#include <getopt.h>
#include <stdio.h>
+#include <signal.h>
+#include <errno.h>
#include <sys/types.h>
#include "system.h"
@@ -521,7 +523,8 @@
while (n--)
{
- if (UT_USER (utmp_buf)[0] && UT_TYPE (utmp_buf) == USER_PROCESS)
+ if (UT_USER (utmp_buf)[0] && UT_TYPE (utmp_buf) == USER_PROCESS &&
+ !(kill(utmp_buf->ut_pid, 0) < 0 && errno == ESRCH))
{
char *trimmed_name;
@@ -567,7 +570,8 @@
strncmp (ttyname_b, utmp_buf->ut_line,
sizeof (utmp_buf->ut_line)) == 0)
{
- if (need_users && IS_USER_PROCESS (utmp_buf))
+ if (need_users && IS_USER_PROCESS (utmp_buf) &&
+ !(kill(utmp_buf->ut_pid, 0) < 0 && errno == ESRCH))
print_user (utmp_buf);
else if (need_runlevel && UT_TYPE (utmp_buf) == RUN_LVL)
print_runlevel (utmp_buf);
- [patch] who and stale utmp entries,
Tim Waugh <=