diff options
author | Volodymyr Vasiutyk <volodymyr.vasiutyk@gmail.com> | 2021-10-06 10:45:07 +0300 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-10-31 15:07:00 +0100 |
commit | 2ef70ad7f692686710091132978129b614f6dd1a (patch) | |
tree | 448c24ac798a6ab5bc18ac37cd9517bddc9f3a73 /linux/Platform.c | |
parent | 2977414d540c9cb78baa3d7fc612fcb4d6ecc72f (diff) |
Early program termination only from main()
Diffstat (limited to 'linux/Platform.c')
-rw-r--r-- | linux/Platform.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/linux/Platform.c b/linux/Platform.c index e7f3d8f0..93953e86 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -835,7 +835,7 @@ void Platform_longOptionsUsage(const char* name) #endif } -bool Platform_getLongOption(int opt, int argc, char** argv) { +CommandLineStatus Platform_getLongOption(int opt, int argc, char** argv) { #ifndef HAVE_LIBCAP (void) argc; (void) argv; @@ -858,16 +858,16 @@ bool Platform_getLongOption(int opt, int argc, char** argv) { Platform_capabilitiesMode = CAP_MODE_STRICT; } else { fprintf(stderr, "Error: invalid capabilities mode \"%s\".\n", mode); - exit(1); + return STATUS_ERROR_EXIT; } - return true; + return STATUS_OK; } #endif default: break; } - return false; + return STATUS_ERROR_EXIT; } #ifdef HAVE_LIBCAP @@ -956,20 +956,22 @@ static int dropCapabilities(enum CapMode mode) { } #endif -void Platform_init(void) { +bool Platform_init(void) { #ifdef HAVE_LIBCAP if (dropCapabilities(Platform_capabilitiesMode) < 0) - exit(1); + return false; #endif if (access(PROCDIR, R_OK) != 0) { fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR); - exit(1); + return false; } #ifdef HAVE_SENSORS_SENSORS_H LibSensors_init(); #endif + + return true; } void Platform_done(void) { |