diff options
author | Nathan Scott <nathans@redhat.com> | 2020-11-19 12:32:07 +1100 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2020-11-19 12:32:07 +1100 |
commit | c75c5ef9c6631127e5c0f3ace4b59e4acadd04e5 (patch) | |
tree | b34cc2a215743f92f063bb4e1578a6888181992a /linux/Platform.c | |
parent | 329011bb982b7dda02e6901173e6fc34bcaa2645 (diff) |
Minor cleanups to platform-specific init and done
Move platform-specific code out of the htop.c main function
and into the platform sub-directories - primarily this is
the Linux procfs path check and sensors setup/teardown; not
needed on any other platforms. No functional changes here.
Diffstat (limited to 'linux/Platform.c')
-rw-r--r-- | linux/Platform.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/linux/Platform.c b/linux/Platform.c index 7c58d3a8..b8b92381 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -56,11 +56,12 @@ in the source distribution for its full text. #include "zfs/ZfsArcStats.h" #include "zfs/ZfsCompressedArcMeter.h" +#ifdef HAVE_LIBSENSORS +#include <sensors/sensors.h> +#endif ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, (int)M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; -//static ProcessField defaultIoFields[] = { PID, IO_PRIORITY, USER, IO_READ_RATE, IO_WRITE_RATE, IO_RATE, COMM, 0 }; - int Platform_numberOfFields = LAST_PROCESSFIELD; const SignalItem Platform_signals[] = { @@ -107,6 +108,22 @@ static time_t Platform_Battery_cacheTime; static double Platform_Battery_cacheLevel = NAN; static ACPresence Platform_Battery_cacheIsOnAC; +void Platform_init(void) { + if (access(PROCDIR, R_OK) != 0) { + fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR); + exit(1); + } +#ifdef HAVE_LIBSENSORS + sensors_init(NULL); +#endif +} + +void Platform_done(void) { +#ifdef HAVE_LIBSENSORS + sensors_cleanup(); +#endif +} + static Htop_Reaction Platform_actionSetIOPriority(State* st) { Panel* panel = st->panel; |