https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ee1ad64234b61f9deaae64b28313492188c1de43

commit ee1ad64234b61f9deaae64b28313492188c1de43
Author: Brian Inglis <brian.ing...@systematicsw.ab.ca>
Date:   Sat Mar 23 20:22:38 2019 -0600

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

Diff:
---
 winsup/utils/ps.cc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc
index 4fce3e0..c81805a 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)
+           {
+             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];

Reply via email to