diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-05-19 19:06:34 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2021-05-20 16:43:40 +0200 |
commit | 6b57898034f7b38d4dc26dc1d5fa718013a12472 (patch) | |
tree | e347e9642429aa12770cb4013adbd172101fb567 /solaris | |
parent | 906dcf5cb3d42618fb4bd6aa14c81a009f7cd596 (diff) |
Solaris: reduce variable scope
Also check for getloadavg(3c) failure
Diffstat (limited to 'solaris')
-rw-r--r-- | solaris/Platform.c | 10 | ||||
-rw-r--r-- | solaris/Platform.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c index 06b6c357..1d4568a0 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -39,8 +39,6 @@ in the source distribution for its full text. #include "SolarisProcessList.h" -double plat_loadavg[3] = {0}; - const SignalItem Platform_signals[] = { { .name = " 0 Cancel", .number = 0 }, { .name = " 1 SIGHUP", .number = 1 }, @@ -152,7 +150,13 @@ int Platform_getUptime() { } void Platform_getLoadAverage(double* one, double* five, double* fifteen) { - getloadavg( plat_loadavg, 3 ); + double plat_loadavg[3]; + if (getloadavg( plat_loadavg, 3 ) < 0) { + *one = NAN; + *five = NAN; + *fifteen = NAN; + return; + } *one = plat_loadavg[LOADAVG_1MIN]; *five = plat_loadavg[LOADAVG_5MIN]; *fifteen = plat_loadavg[LOADAVG_15MIN]; diff --git a/solaris/Platform.h b/solaris/Platform.h index fc2826bb..cf94fbb3 100644 --- a/solaris/Platform.h +++ b/solaris/Platform.h @@ -42,8 +42,6 @@ typedef struct envAccum_ { char* env; } envAccum; -extern double plat_loadavg[3]; - extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; |