From ec8e547be135cc638db3615c9335fb3d04caf17f Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Mon, 26 Oct 2020 05:27:10 +0000 Subject: [PATCH] main: don't renice as non-root on non-Linux On BSD systems only the super-user may lower priority values. meson.build:40:0: ERROR: Dependency "libcap" not found, tried pkgconfig and cmake src/main.cpp:7:10: fatal error: 'sys/capability.h' file not found #include ^~~~~~~~~~~~~~~~~~ src/main.cpp:244:2: error: unknown type name 'cap_t' cap_t caps = cap_get_proc(); ^ src/main.cpp:244:15: error: use of undeclared identifier 'cap_get_proc' cap_t caps = cap_get_proc(); ^ src/main.cpp:247:3: error: unknown type name 'cap_flag_value_t' cap_flag_value_t nicecapvalue = CAP_CLEAR; ^ src/main.cpp:247:35: error: use of undeclared identifier 'CAP_CLEAR' cap_flag_value_t nicecapvalue = CAP_CLEAR; ^ src/main.cpp:248:23: error: use of undeclared identifier 'CAP_SYS_NICE' cap_get_flag( caps, CAP_SYS_NICE, CAP_EFFECTIVE, &nicecapvalue ); ^ src/main.cpp:248:37: error: use of undeclared identifier 'CAP_EFFECTIVE' cap_get_flag( caps, CAP_SYS_NICE, CAP_EFFECTIVE, &nicecapvalue ); ^ src/main.cpp:250:24: error: use of undeclared identifier 'CAP_SET' if ( nicecapvalue == CAP_SET ) ^ --- meson.build | 2 +- src/main.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index e7251ec043..957d9f0e55 100644 --- a/meson.build +++ b/meson.build @@ -37,7 +37,7 @@ wayland_server = dependency('wayland-server') wayland_protos = dependency('wayland-protocols', version: '>=1.17') xkbcommon = dependency('xkbcommon') thread_dep = dependency('threads') -cap_dep = dependency('libcap') +cap_dep = dependency('libcap', required: false) sdl_dep = dependency('SDL2') pipewire_dep = dependency('libpipewire-0.3', required: get_option('pipewire')) diff --git a/src/main.cpp b/src/main.cpp index 08d9e15846..7298f7b30d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,9 @@ #include #include #include +#if defined(__linux__) #include +#endif #include #include @@ -241,6 +243,7 @@ int main(int argc, char **argv) } } +#if defined(__linux__) cap_t caps = cap_get_proc(); if ( caps != nullptr ) { @@ -271,6 +274,7 @@ int main(int argc, char **argv) { fprintf( stderr, "No CAP_SYS_NICE, falling back to regular-priority compute and threads.\nPerformance will be affected.\n" ); } +#endif if ( gpuvis_trace_init() != -1 ) {