winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument
Adresses the problem reported here: https://cygwin.com/ml/cygwin/2019-09/msg00141.html
This commit is contained in:
parent
9103de7028
commit
7513fee1bb
|
@ -72,12 +72,17 @@ times (struct tms *buf)
|
||||||
/* ticks is in in 100ns, convert to clock ticks. */
|
/* ticks is in in 100ns, convert to clock ticks. */
|
||||||
tc = (clock_t) (ticks.QuadPart * CLOCKS_PER_SEC / NS100PERSEC);
|
tc = (clock_t) (ticks.QuadPart * CLOCKS_PER_SEC / NS100PERSEC);
|
||||||
|
|
||||||
buf->tms_stime = __to_clock_t (&kut.KernelTime, 0);
|
/* Linux allows a NULL buf and just returns tc in that case, so
|
||||||
buf->tms_utime = __to_clock_t (&kut.UserTime, 0);
|
mimic that */
|
||||||
timeval_to_filetime (&myself->rusage_children.ru_stime, &kut.KernelTime);
|
if (buf)
|
||||||
buf->tms_cstime = __to_clock_t (&kut.KernelTime, 1);
|
{
|
||||||
timeval_to_filetime (&myself->rusage_children.ru_utime, &kut.UserTime);
|
buf->tms_stime = __to_clock_t (&kut.KernelTime, 0);
|
||||||
buf->tms_cutime = __to_clock_t (&kut.UserTime, 1);
|
buf->tms_utime = __to_clock_t (&kut.UserTime, 0);
|
||||||
|
timeval_to_filetime (&myself->rusage_children.ru_stime, &kut.KernelTime);
|
||||||
|
buf->tms_cstime = __to_clock_t (&kut.KernelTime, 1);
|
||||||
|
timeval_to_filetime (&myself->rusage_children.ru_utime, &kut.UserTime);
|
||||||
|
buf->tms_cutime = __to_clock_t (&kut.UserTime, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
__except (EFAULT)
|
__except (EFAULT)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue