R-ps/0001-Handle-failure-from-sysconf.patch
2018-09-05 17:15:00 -04:00

43 lines
1.1 KiB
Diff

From 00349771f69aa23f4ece4d0ec42566755460fce2 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Wed, 5 Sep 2018 04:50:12 -0400
Subject: [PATCH 1/3] Handle failure from sysconf.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
src/api-linux.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/api-linux.c b/src/api-linux.c
index f2995df..02f6268 100644
--- a/src/api-linux.c
+++ b/src/api-linux.c
@@ -261,8 +261,12 @@ int psll_linux_get_boot_time() {
return 0;
}
-int psll_linux_get_clock_ticks() {
+int psll_linux_get_clock_ticks(void) {
psll_linux_clock_ticks = sysconf(_SC_CLK_TCK);
+ if (psll_linux_clock_ticks == -1) {
+ ps__set_error_from_errno();
+ return -1;
+ }
return 0;
}
@@ -278,7 +282,9 @@ int psll_linux_ctime(long pid, double *ctime) {
if (!psll_linux_clock_ticks) {
ret = psll_linux_get_clock_ticks();
- if (ret) return ret;
+ if (ret) {
+ ps__throw_error();
+ }
}
*ctime = psll_linux_boot_time + stat.starttime / psll_linux_clock_ticks;
--
2.17.1