diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-03-14 15:25:15 +0000 |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-03-14 15:25:15 +0000 |
commit | 4e5c96697510c3feecae27d8bd4c4086751ca945 (patch) | |
tree | 9ac427071c6317ae6ee6d2effa5db3e5781b0143 | |
parent | f494ae924c603396cd9b9b1477bdef899d6baaf9 (diff) | |
download | psutil-4e5c96697510c3feecae27d8bd4c4086751ca945.tar.gz |
(FreeBSD) fix BOOT_TIME: the time reported was wrong because we weren't passing the right type to Py_BuildValue() (also refactored it a little bit)
-rw-r--r-- | psutil/_psutil_bsd.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c index 1912507a..8ca5eb7f 100644 --- a/psutil/_psutil_bsd.c +++ b/psutil/_psutil_bsd.c @@ -152,16 +152,14 @@ get_system_boot_time(PyObject* self, PyObject* args) { /* fetch sysctl "kern.boottime" */ static int request[2] = { CTL_KERN, KERN_BOOTTIME }; - struct timeval result; - size_t result_len = sizeof result; - time_t boot_time = 0; + struct timeval boottime; + size_t len = sizeof(boottime); - if (sysctl(request, 2, &result, &result_len, NULL, 0) == -1) { + if (sysctl(request, 2, &boottime, &len, NULL, 0) == -1) { PyErr_SetFromErrno(0); return NULL; } - boot_time = result.tv_sec; - return Py_BuildValue("f", (float)boot_time); + return Py_BuildValue("I", (unsigned int)boottime.tv_sec); } |