Eric Blake wrote:

> On 09/05/2012 02:08 PM, Mats Erik Andersson wrote:
>> Dear all,
>>
>> the module readutmp is broken for the standard use
>>
>>   read_utmp(..., READ_UTMP_USER_PROCESS | READ_UTMP_CHECK_PIDS)
>>
>> for all releases of FreeBSD until 8.3, and all OpenBSD ever released.
>
> Thanks for the report.
>
>>
>>>From 60fcbc2763d6b657c62b921ed263fbd5a0794df6 Mon Sep 17 00:00:00 2001
>> From: Mats Erik Andersson <g...@gisladisker.se>
>> Date: Wed, 5 Sep 2012 21:51:39 +0200
>> Subject: [PATCH] readutmp.c: Portability improved UT_PID use.
>>
>> * lib/readutmp.c (desirable_utmp_entry) <READ_UTMP_CHECK_PIDS>:
>>   Use `UT_PID (u) > 0' as absolute condition.
>
> I like this version better, as we like avoiding in-function #ifdef when
> possible.  I'll push it shortly, with one tweak...
>
>> ---
>>  lib/readutmp.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/readutmp.c b/lib/readutmp.c
>> index f89dd68..2ac803b 100644
>> --- a/lib/readutmp.c
>> +++ b/lib/readutmp.c
>> @@ -69,8 +69,8 @@ desirable_utmp_entry (STRUCT_UTMP const *u, int options)
>>      return false;
>>    if ((options & READ_UTMP_CHECK_PIDS)
>>        && user_proc
>> -      && (UT_PID (u) <= 0
>> -          || (kill (UT_PID (u), 0) < 0 && errno == ESRCH)))
>> +      && UT_PID (u) > 0
>
> Jim likes favoring < over >, so I'm swapping this to '0 < UT_PID (u)'.

Thanks Mats and Eric.  That looks fine.

Reply via email to