[PATCH] default ps -W process start time to system boot time when inaccessible, 0, -1

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Sat Mar 23 20:24:00 GMT 2019


On 2019-03-23 11:04, Corinna Vinschen wrote:
> On Mar 22 21:45, Brian Inglis wrote:
>> diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc
>> index 4fce3e0b3..c81805ab6 100644
>> --- a/winsup/utils/ps.cc
>> +++ b/winsup/utils/ps.cc
>> @@ -337,6 +337,17 @@ main (int argc, char *argv[])
>>  		p->start_time = to_time_t (&ct);
>>  	      CloseHandle (h);
>>  	    }
>> +	  if (!h || 0 == p->start_time || -1 == p->start_time)
> 
>           if (!h || !p->start_time)
> 
> should be sufficient.  cygwin_internal(CW_GETPINFO_FULL) memsets the
> struct returned to all 0 before filling it with available data.

Case -1 is an invalid time_t conversion - everything else is valid! ;^>

>> +	    {
>> +	      SYSTEM_TIMEOFDAY_INFORMATION stodi;
>> +	      status = NtQuerySystemInformation (SystemTimeOfDayInformation,
>> +					(PVOID) &stodi, sizeof stodi, NULL);
>> +	      if (!NT_SUCCESS (status))
>> +		fprintf (stderr,
>> +			"NtQuerySystemInformation(SystemTimeOfDayInformation), "
>> +					"status %08x", status);
>> +	      p->start_time = to_time_t ((FILETIME*)&stodi.BootTime);
>> +	    }
>>  	}
>>  
>>        char uname[128];
> Wouldn't it make sense to fetch SystemTimeOfDayInformation only once
> and then just set p->start_time above?
Yea - thought about doing that - will redo that way.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.



More information about the Cygwin-patches mailing list